@payloadcms/figma 0.0.1-alpha.9 → 0.1.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/control-plane.d.ts +56 -7
- package/dist/api/control-plane.js +188 -74
- package/dist/api/error-response.d.ts +36 -0
- package/dist/api/error-response.js +66 -0
- package/dist/api/figma-api.d.ts +24 -3
- package/dist/api/figma-api.js +110 -34
- package/dist/auth/browser.d.ts +0 -1
- package/dist/auth/browser.js +0 -2
- package/dist/auth/callback-server.d.ts +19 -8
- package/dist/auth/callback-server.js +72 -32
- package/dist/auth/credentials.d.ts +20 -0
- package/dist/auth/credentials.js +19 -0
- package/dist/auth/crypto-utils.d.ts +28 -1
- package/dist/auth/crypto-utils.js +132 -23
- package/dist/auth/jwt-validator.d.ts +23 -6
- package/dist/auth/jwt-validator.js +35 -9
- package/dist/auth/oauth-flow.d.ts +19 -4
- package/dist/auth/oauth-flow.js +151 -34
- package/dist/auth/paste-code.d.ts +33 -0
- package/dist/auth/paste-code.js +87 -0
- package/dist/auth/pkce.d.ts +0 -1
- package/dist/auth/pkce.js +0 -2
- package/dist/auth/project-token.d.ts +32 -17
- package/dist/auth/project-token.js +176 -68
- package/dist/auth/refresh.d.ts +2 -2
- package/dist/auth/refresh.js +25 -14
- package/dist/auth/token-store-migration.d.ts +57 -0
- package/dist/auth/token-store-migration.js +154 -0
- package/dist/auth/token-store.d.ts +63 -98
- package/dist/auth/token-store.js +405 -124
- package/dist/auth/types.d.ts +40 -6
- package/dist/auth/types.js +1 -3
- package/dist/cli.d.ts +0 -1
- package/dist/cli.js +102 -8
- package/dist/commands/bootstrap.d.ts +17 -0
- package/dist/commands/bootstrap.js +88 -0
- package/dist/commands/build-lambda-zip.d.ts +4 -0
- package/dist/commands/build-lambda-zip.js +17 -0
- package/dist/commands/debug.d.ts +7 -0
- package/dist/commands/debug.js +178 -0
- package/dist/commands/deploy.d.ts +11 -1
- package/dist/commands/deploy.js +193 -153
- package/dist/commands/dump-tokens.d.ts +11 -0
- package/dist/commands/dump-tokens.js +67 -0
- package/dist/commands/env.d.ts +12 -0
- package/dist/commands/env.js +86 -0
- package/dist/commands/init.d.ts +9 -6
- package/dist/commands/init.js +232 -152
- package/dist/commands/list-tokens.d.ts +3 -4
- package/dist/commands/list-tokens.js +24 -11
- package/dist/commands/login.d.ts +8 -2
- package/dist/commands/login.js +34 -18
- package/dist/commands/logout.d.ts +5 -5
- package/dist/commands/logout.js +77 -17
- package/dist/commands/upgrade.d.ts +4 -0
- package/dist/commands/upgrade.js +329 -0
- package/dist/commands/upload-schema.d.ts +8 -0
- package/dist/commands/upload-schema.js +91 -0
- package/dist/config/oauth.d.ts +17 -12
- package/dist/config/oauth.js +38 -39
- package/dist/constants.d.ts +63 -19
- package/dist/constants.js +158 -20
- package/dist/db-content-api/generated/content-api-types.d.ts +8215 -0
- package/dist/db-content-api/generated/content-api-types.js +5 -0
- package/dist/db-content-api/index.d.ts +40 -0
- package/dist/db-content-api/index.js +883 -0
- package/dist/db-content-api/temp-utilities/slug.d.ts +1 -0
- package/dist/db-content-api/temp-utilities/slug.js +1 -0
- package/dist/db-content-api/temp-utilities/sorting.d.ts +2 -0
- package/dist/db-content-api/temp-utilities/sorting.js +37 -0
- package/dist/db-content-api/temp-utilities/types.d.ts +21 -0
- package/dist/db-content-api/temp-utilities/types.js +13 -0
- package/dist/db-content-api/temp-utilities/unwrapDocument.d.ts +38 -0
- package/dist/db-content-api/temp-utilities/unwrapDocument.js +62 -0
- package/dist/db-content-api/utilities/auth.d.ts +29 -0
- package/dist/db-content-api/utilities/auth.js +82 -0
- package/dist/db-content-api/utilities/clientVersionHeaders.d.ts +7 -0
- package/dist/db-content-api/utilities/clientVersionHeaders.js +15 -0
- package/dist/db-content-api/utilities/data/applyDefaults.d.ts +6 -0
- package/dist/db-content-api/utilities/data/applyDefaults.js +75 -0
- package/dist/db-content-api/utilities/data/atomicOperations.d.ts +16 -0
- package/dist/db-content-api/utilities/data/atomicOperations.js +48 -0
- package/dist/db-content-api/utilities/data/castFieldValue.d.ts +10 -0
- package/dist/db-content-api/utilities/data/castFieldValue.js +66 -0
- package/dist/db-content-api/utilities/data/convertRelationshipIds.d.ts +25 -0
- package/dist/db-content-api/utilities/data/convertRelationshipIds.js +109 -0
- package/dist/db-content-api/utilities/data/index.d.ts +48 -0
- package/dist/db-content-api/utilities/data/index.js +315 -0
- package/dist/db-content-api/utilities/data/isLocaleMap.d.ts +10 -0
- package/dist/db-content-api/utilities/data/isLocaleMap.js +13 -0
- package/dist/db-content-api/utilities/data/pointShape.d.ts +3 -0
- package/dist/db-content-api/utilities/data/pointShape.js +43 -0
- package/dist/db-content-api/utilities/data/removeVirtualFields.d.ts +11 -0
- package/dist/db-content-api/utilities/data/removeVirtualFields.js +52 -0
- package/dist/db-content-api/utilities/data/resolveFieldLocalization.d.ts +18 -0
- package/dist/db-content-api/utilities/data/resolveFieldLocalization.js +21 -0
- package/dist/db-content-api/utilities/data/richTextShape.d.ts +3 -0
- package/dist/db-content-api/utilities/data/richTextShape.js +56 -0
- package/dist/db-content-api/utilities/data/stripFields.d.ts +47 -0
- package/dist/db-content-api/utilities/data/stripFields.js +170 -0
- package/dist/db-content-api/utilities/data/transformPublishedLocale.d.ts +22 -0
- package/dist/db-content-api/utilities/data/transformPublishedLocale.js +40 -0
- package/dist/db-content-api/utilities/data/validateRelationships.d.ts +6 -0
- package/dist/db-content-api/utilities/data/validateRelationships.js +107 -0
- package/dist/db-content-api/utilities/joins.d.ts +50 -0
- package/dist/db-content-api/utilities/joins.js +124 -0
- package/dist/db-content-api/utilities/locale/index.d.ts +9 -0
- package/dist/db-content-api/utilities/locale/index.js +19 -0
- package/dist/db-content-api/utilities/meta/normalizeLocaleInWhere.d.ts +9 -0
- package/dist/db-content-api/utilities/meta/normalizeLocaleInWhere.js +100 -0
- package/dist/db-content-api/utilities/resolveBlocks.d.ts +19 -0
- package/dist/db-content-api/utilities/resolveBlocks.js +31 -0
- package/dist/db-content-api/utilities/schema/buildDocumentSchema.d.ts +72 -0
- package/dist/db-content-api/utilities/schema/buildDocumentSchema.js +264 -0
- package/dist/db-content-api/utilities/where.d.ts +9 -0
- package/dist/db-content-api/utilities/where.js +95 -0
- package/dist/deploy/schedule-extract-plugin.d.ts +10 -0
- package/dist/deploy/schedule-extract-plugin.js +32 -0
- package/dist/endpoints/health.d.ts +2 -0
- package/dist/endpoints/health.js +9 -0
- package/dist/endpoints/schema.d.ts +2 -0
- package/dist/endpoints/schema.js +27 -0
- package/dist/exports/client.d.ts +2 -1
- package/dist/exports/client.js +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -3
- package/dist/lib/download-skill.d.ts +12 -0
- package/dist/lib/download-skill.js +77 -0
- package/dist/oauth/components/FigmaAvatar/index.d.ts +3 -0
- package/dist/oauth/components/FigmaAvatar/index.js +25 -0
- package/dist/oauth/components/FigmaAvatar/index.scss +12 -0
- package/dist/oauth/components/FigmaAvatarCell/index.d.ts +4 -0
- package/dist/oauth/components/FigmaAvatarCell/index.js +23 -0
- package/dist/oauth/components/FigmaAvatarCell/index.scss +5 -0
- package/dist/oauth/components/FigmaAvatarPlaceholder/index.d.ts +8 -0
- package/dist/oauth/components/FigmaAvatarPlaceholder/index.js +35 -0
- package/dist/oauth/components/FigmaAvatarPlaceholder/index.scss +28 -0
- package/dist/oauth/components/LoginButton/iframeAutoLogin.d.ts +81 -0
- package/dist/oauth/components/LoginButton/iframeAutoLogin.js +168 -0
- package/dist/oauth/components/LoginButton/index.d.ts +0 -1
- package/dist/oauth/components/LoginButton/index.js +156 -18
- package/dist/oauth/components/LoginButton/index.scss +75 -3
- package/dist/oauth/components/LogoutButton/index.d.ts +0 -1
- package/dist/oauth/components/LogoutButton/index.js +20 -9
- package/dist/oauth/defaults.d.ts +3 -2
- package/dist/oauth/defaults.js +79 -12
- package/dist/oauth/endpoints/getLoginEndpoint.d.ts +0 -1
- package/dist/oauth/endpoints/getLoginEndpoint.js +87 -84
- package/dist/oauth/endpoints/getLogoutEndpoint.d.ts +0 -1
- package/dist/oauth/endpoints/getLogoutEndpoint.js +7 -6
- package/dist/oauth/endpoints/getMetaEndpoint.d.ts +0 -1
- package/dist/oauth/endpoints/getMetaEndpoint.js +18 -5
- package/dist/oauth/endpoints/getRedirectToLoginEndpoint.d.ts +0 -1
- package/dist/oauth/endpoints/getRedirectToLoginEndpoint.js +11 -4
- package/dist/oauth/exports/client.d.ts +0 -1
- package/dist/oauth/exports/client.js +0 -2
- package/dist/oauth/hooks/afterLogout.d.ts +0 -1
- package/dist/oauth/hooks/afterLogout.js +0 -2
- package/dist/oauth/hooks/me.d.ts +0 -1
- package/dist/oauth/hooks/me.js +0 -2
- package/dist/oauth/hooks/refresh.d.ts +0 -1
- package/dist/oauth/hooks/refresh.js +2 -3
- package/dist/oauth/index.d.ts +0 -1
- package/dist/oauth/index.js +27 -7
- package/dist/oauth/strategy/index.d.ts +0 -3
- package/dist/oauth/strategy/index.js +55 -34
- package/dist/oauth/types.d.ts +23 -7
- package/dist/oauth/types.js +0 -2
- package/dist/oauth/utilities/buildUnauthorizedRedirect.d.ts +14 -0
- package/dist/oauth/utilities/buildUnauthorizedRedirect.js +28 -0
- package/dist/oauth/utilities/clearCookie.d.ts +0 -1
- package/dist/oauth/utilities/clearCookie.js +5 -3
- package/dist/oauth/utilities/createCookieOptions.d.ts +0 -1
- package/dist/oauth/utilities/createCookieOptions.js +9 -4
- package/dist/oauth/utilities/createDebugLogger.d.ts +0 -1
- package/dist/oauth/utilities/createDebugLogger.js +0 -2
- package/dist/oauth/utilities/establishSession.d.ts +22 -0
- package/dist/oauth/utilities/establishSession.js +80 -0
- package/dist/oauth/utilities/exchangeCodeForAccessToken.d.ts +23 -0
- package/dist/oauth/utilities/exchangeCodeForAccessToken.js +26 -0
- package/dist/oauth/utilities/extractOrigin.d.ts +0 -1
- package/dist/oauth/utilities/extractOrigin.js +0 -2
- package/dist/oauth/utilities/figmaHostnames.d.ts +2 -0
- package/dist/oauth/utilities/figmaHostnames.js +24 -0
- package/dist/oauth/utilities/getAdminCollectionSlug.d.ts +0 -1
- package/dist/oauth/utilities/getAdminCollectionSlug.js +0 -2
- package/dist/oauth/utilities/getAuthorizeURL.d.ts +65 -2
- package/dist/oauth/utilities/getAuthorizeURL.js +57 -4
- package/dist/oauth/utilities/getCookieExpiration.d.ts +0 -1
- package/dist/oauth/utilities/getCookieExpiration.js +0 -2
- package/dist/oauth/utilities/getSecondsFromTokenExp.d.ts +0 -1
- package/dist/oauth/utilities/getSecondsFromTokenExp.js +0 -2
- package/dist/oauth/utilities/getTokenExp.d.ts +0 -1
- package/dist/oauth/utilities/getTokenExp.js +0 -2
- package/dist/oauth/utilities/getUsernameField.d.ts +0 -1
- package/dist/oauth/utilities/getUsernameField.js +0 -2
- package/dist/oauth/utilities/hasUserTokenPropsChanged.d.ts +0 -1
- package/dist/oauth/utilities/hasUserTokenPropsChanged.js +0 -2
- package/dist/oauth/utilities/isAbsoluteURL.d.ts +1 -0
- package/dist/oauth/utilities/isAbsoluteURL.js +1 -0
- package/dist/oauth/utilities/isDuplicateKeyError.d.ts +6 -0
- package/dist/oauth/utilities/isDuplicateKeyError.js +12 -0
- package/dist/oauth/utilities/mergeHeaders.d.ts +0 -1
- package/dist/oauth/utilities/mergeHeaders.js +0 -2
- package/dist/oauth/utilities/refreshTokens.d.ts +0 -1
- package/dist/oauth/utilities/refreshTokens.js +21 -13
- package/dist/oauth/utilities/withPartitionedCookie.d.ts +19 -0
- package/dist/oauth/utilities/withPartitionedCookie.js +26 -0
- package/dist/oauth/utils/getSearchParam.d.ts +17 -0
- package/dist/oauth/utils/getSearchParam.js +22 -0
- package/dist/plugin/adapter.d.ts +0 -1
- package/dist/plugin/adapter.js +0 -2
- package/dist/plugin/auth-preflight.d.ts +7 -0
- package/dist/plugin/auth-preflight.js +18 -0
- package/dist/plugin/bootstrap-preflight.d.ts +22 -0
- package/dist/plugin/bootstrap-preflight.js +43 -0
- package/dist/plugin/build-config.d.ts +27 -15
- package/dist/plugin/build-config.js +380 -16
- package/dist/plugin/dev-cookie-names.d.ts +13 -0
- package/dist/plugin/dev-cookie-names.js +17 -0
- package/dist/scss.d.js +2 -0
- package/dist/storage-content-api/api-types.d.ts +183 -0
- package/dist/storage-content-api/api-types.js +4 -0
- package/dist/storage-content-api/client-uploads/generate.d.ts +14 -0
- package/dist/storage-content-api/client-uploads/generate.js +69 -0
- package/dist/storage-content-api/client.d.ts +5 -0
- package/dist/storage-content-api/client.js +37 -0
- package/dist/storage-content-api/generateURL.d.ts +6 -0
- package/dist/storage-content-api/generateURL.js +6 -0
- package/dist/storage-content-api/handleDelete.d.ts +7 -0
- package/dist/storage-content-api/handleDelete.js +15 -0
- package/dist/storage-content-api/handleUpload.d.ts +10 -0
- package/dist/storage-content-api/handleUpload.js +162 -0
- package/dist/storage-content-api/index.d.ts +4 -0
- package/dist/storage-content-api/index.js +37 -0
- package/dist/storage-content-api/staticHandler.d.ts +9 -0
- package/dist/storage-content-api/staticHandler.js +61 -0
- package/dist/storage-content-api/types.d.ts +9 -0
- package/dist/storage-content-api/types.js +1 -0
- package/dist/storage-content-api/utilities/getSafeFilename.d.ts +11 -0
- package/dist/storage-content-api/utilities/getSafeFilename.js +59 -0
- package/dist/storage-content-api/utilities/index.d.ts +2 -0
- package/dist/storage-content-api/utilities/index.js +2 -0
- package/dist/storage-content-api/utilities/parseUploadReference.d.ts +17 -0
- package/dist/storage-content-api/utilities/parseUploadReference.js +27 -0
- package/dist/templates/.env.example +5 -0
- package/dist/templates/README.md +19 -0
- package/dist/types/config.d.ts +2 -2
- package/dist/types/config.js +0 -4
- package/dist/types.d.ts +10 -2
- package/dist/types.js +0 -2
- package/dist/utils/adapters/nextjs.d.ts +8 -0
- package/dist/utils/adapters/nextjs.js +61 -0
- package/dist/utils/adapters/nitro.d.ts +8 -0
- package/dist/utils/adapters/nitro.js +172 -0
- package/dist/utils/adapters/vite.d.ts +9 -0
- package/dist/utils/adapters/vite.js +31 -0
- package/dist/utils/asset-collection.d.ts +27 -7
- package/dist/utils/asset-collection.js +59 -32
- package/dist/utils/build-detection.d.ts +5 -12
- package/dist/utils/build-detection.js +74 -13
- package/dist/utils/build-lambda-zip.d.ts +25 -0
- package/dist/utils/build-lambda-zip.js +90 -0
- package/dist/utils/cache-bootstrap.d.ts +7 -0
- package/dist/utils/cache-bootstrap.js +16 -0
- package/dist/utils/config.d.ts +0 -1
- package/dist/utils/config.js +1 -3
- package/dist/utils/deploy-adapter.d.ts +45 -0
- package/dist/utils/deploy-adapter.js +56 -0
- package/dist/utils/download-template.d.ts +9 -2
- package/dist/utils/download-template.js +24 -20
- package/dist/utils/env-management.d.ts +24 -8
- package/dist/utils/env-management.js +119 -66
- package/dist/utils/format-env-suffix.d.ts +11 -0
- package/dist/utils/format-env-suffix.js +11 -0
- package/dist/utils/format.d.ts +0 -1
- package/dist/utils/format.js +0 -2
- package/dist/utils/formatter.d.ts +0 -1
- package/dist/utils/formatter.js +23 -13
- package/dist/utils/fs-utils.d.ts +12 -0
- package/dist/utils/fs-utils.js +55 -0
- package/dist/utils/git.d.ts +0 -1
- package/dist/utils/git.js +0 -2
- package/dist/utils/handle-upgrade.d.ts +8 -0
- package/dist/utils/handle-upgrade.js +39 -0
- package/dist/utils/is-debug.d.ts +0 -1
- package/dist/utils/is-debug.js +0 -2
- package/dist/utils/lambda-config.d.ts +3 -2
- package/dist/utils/lambda-config.js +75 -80
- package/dist/utils/load-payload-config.d.ts +9 -0
- package/dist/utils/load-payload-config.js +27 -0
- package/dist/utils/log.d.ts +0 -1
- package/dist/utils/log.js +0 -2
- package/dist/utils/messages.d.ts +1 -3
- package/dist/utils/messages.js +47 -13
- package/dist/utils/package-manager.d.ts +24 -1
- package/dist/utils/package-manager.js +53 -2
- package/dist/utils/parse-template-spec.d.ts +11 -0
- package/dist/utils/parse-template-spec.js +60 -0
- package/dist/utils/payload-config-ast.d.ts +27 -7
- package/dist/utils/payload-config-ast.js +106 -60
- package/dist/utils/payload-config-finder.d.ts +2 -3
- package/dist/utils/payload-config-finder.js +48 -11
- package/dist/utils/payload-config-modifier.d.ts +1 -2
- package/dist/utils/payload-config-modifier.js +114 -68
- package/dist/utils/payload-package-check.d.ts +28 -3
- package/dist/utils/payload-package-check.js +90 -31
- package/dist/utils/project.d.ts +8 -4
- package/dist/utils/project.js +63 -37
- package/dist/utils/resolve-environment.d.ts +13 -0
- package/dist/utils/resolve-environment.js +29 -0
- package/dist/utils/s3-upload.d.ts +7 -3
- package/dist/utils/s3-upload.js +44 -9
- package/dist/utils/token-display.d.ts +5 -2
- package/dist/utils/token-display.js +49 -24
- package/dist/utils/typescript-validator.d.ts +0 -1
- package/dist/utils/typescript-validator.js +4 -8
- package/dist/utils/version-check.d.ts +2 -0
- package/dist/utils/version-check.js +43 -0
- package/package.json +47 -16
- package/dist/api/control-plane.d.ts.map +0 -1
- package/dist/api/control-plane.js.map +0 -1
- package/dist/api/figma-api.d.ts.map +0 -1
- package/dist/api/figma-api.js.map +0 -1
- package/dist/auth/browser.d.ts.map +0 -1
- package/dist/auth/browser.js.map +0 -1
- package/dist/auth/callback-server.d.ts.map +0 -1
- package/dist/auth/callback-server.js.map +0 -1
- package/dist/auth/crypto-utils.d.ts.map +0 -1
- package/dist/auth/crypto-utils.js.map +0 -1
- package/dist/auth/jwt-validator.d.ts.map +0 -1
- package/dist/auth/jwt-validator.js.map +0 -1
- package/dist/auth/oauth-flow.d.ts.map +0 -1
- package/dist/auth/oauth-flow.js.map +0 -1
- package/dist/auth/pkce.d.ts.map +0 -1
- package/dist/auth/pkce.js.map +0 -1
- package/dist/auth/project-token.d.ts.map +0 -1
- package/dist/auth/project-token.js.map +0 -1
- package/dist/auth/refresh.d.ts.map +0 -1
- package/dist/auth/refresh.js.map +0 -1
- package/dist/auth/token-store.d.ts.map +0 -1
- package/dist/auth/token-store.js.map +0 -1
- package/dist/auth/types.d.ts.map +0 -1
- package/dist/auth/types.js.map +0 -1
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/commands/deploy.d.ts.map +0 -1
- package/dist/commands/deploy.js.map +0 -1
- package/dist/commands/init.d.ts.map +0 -1
- package/dist/commands/init.js.map +0 -1
- package/dist/commands/list-tokens.d.ts.map +0 -1
- package/dist/commands/list-tokens.js.map +0 -1
- package/dist/commands/login.d.ts.map +0 -1
- package/dist/commands/login.js.map +0 -1
- package/dist/commands/logout.d.ts.map +0 -1
- package/dist/commands/logout.js.map +0 -1
- package/dist/config/oauth.d.ts.map +0 -1
- package/dist/config/oauth.js.map +0 -1
- package/dist/constants.d.ts.map +0 -1
- package/dist/constants.js.map +0 -1
- package/dist/exports/client.d.ts.map +0 -1
- package/dist/exports/client.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/oauth/components/LoginButton/index.d.ts.map +0 -1
- package/dist/oauth/components/LoginButton/index.js.map +0 -1
- package/dist/oauth/components/LogoutButton/index.d.ts.map +0 -1
- package/dist/oauth/components/LogoutButton/index.js.map +0 -1
- package/dist/oauth/defaults.d.ts.map +0 -1
- package/dist/oauth/defaults.js.map +0 -1
- package/dist/oauth/endpoints/getLoginEndpoint.d.ts.map +0 -1
- package/dist/oauth/endpoints/getLoginEndpoint.js.map +0 -1
- package/dist/oauth/endpoints/getLogoutEndpoint.d.ts.map +0 -1
- package/dist/oauth/endpoints/getLogoutEndpoint.js.map +0 -1
- package/dist/oauth/endpoints/getMetaEndpoint.d.ts.map +0 -1
- package/dist/oauth/endpoints/getMetaEndpoint.js.map +0 -1
- package/dist/oauth/endpoints/getRedirectToLoginEndpoint.d.ts.map +0 -1
- package/dist/oauth/endpoints/getRedirectToLoginEndpoint.js.map +0 -1
- package/dist/oauth/exports/client.d.ts.map +0 -1
- package/dist/oauth/exports/client.js.map +0 -1
- package/dist/oauth/hooks/afterLogout.d.ts.map +0 -1
- package/dist/oauth/hooks/afterLogout.js.map +0 -1
- package/dist/oauth/hooks/me.d.ts.map +0 -1
- package/dist/oauth/hooks/me.js.map +0 -1
- package/dist/oauth/hooks/refresh.d.ts.map +0 -1
- package/dist/oauth/hooks/refresh.js.map +0 -1
- package/dist/oauth/index.d.ts.map +0 -1
- package/dist/oauth/index.js.map +0 -1
- package/dist/oauth/strategy/index.d.ts.map +0 -1
- package/dist/oauth/strategy/index.js.map +0 -1
- package/dist/oauth/types.d.ts.map +0 -1
- package/dist/oauth/types.js.map +0 -1
- package/dist/oauth/utilities/clearCookie.d.ts.map +0 -1
- package/dist/oauth/utilities/clearCookie.js.map +0 -1
- package/dist/oauth/utilities/createCookieOptions.d.ts.map +0 -1
- package/dist/oauth/utilities/createCookieOptions.js.map +0 -1
- package/dist/oauth/utilities/createDebugLogger.d.ts.map +0 -1
- package/dist/oauth/utilities/createDebugLogger.js.map +0 -1
- package/dist/oauth/utilities/extractOrigin.d.ts.map +0 -1
- package/dist/oauth/utilities/extractOrigin.js.map +0 -1
- package/dist/oauth/utilities/getAdminCollectionSlug.d.ts.map +0 -1
- package/dist/oauth/utilities/getAdminCollectionSlug.js.map +0 -1
- package/dist/oauth/utilities/getAdminPath.d.ts +0 -8
- package/dist/oauth/utilities/getAdminPath.d.ts.map +0 -1
- package/dist/oauth/utilities/getAdminPath.js +0 -9
- package/dist/oauth/utilities/getAdminPath.js.map +0 -1
- package/dist/oauth/utilities/getAuthorizeURL.d.ts.map +0 -1
- package/dist/oauth/utilities/getAuthorizeURL.js.map +0 -1
- package/dist/oauth/utilities/getCookieExpiration.d.ts.map +0 -1
- package/dist/oauth/utilities/getCookieExpiration.js.map +0 -1
- package/dist/oauth/utilities/getSecondsFromTokenExp.d.ts.map +0 -1
- package/dist/oauth/utilities/getSecondsFromTokenExp.js.map +0 -1
- package/dist/oauth/utilities/getTokenExp.d.ts.map +0 -1
- package/dist/oauth/utilities/getTokenExp.js.map +0 -1
- package/dist/oauth/utilities/getUsernameField.d.ts.map +0 -1
- package/dist/oauth/utilities/getUsernameField.js.map +0 -1
- package/dist/oauth/utilities/hasUserTokenPropsChanged.d.ts.map +0 -1
- package/dist/oauth/utilities/hasUserTokenPropsChanged.js.map +0 -1
- package/dist/oauth/utilities/mergeHeaders.d.ts.map +0 -1
- package/dist/oauth/utilities/mergeHeaders.js.map +0 -1
- package/dist/oauth/utilities/refreshTokens.d.ts.map +0 -1
- package/dist/oauth/utilities/refreshTokens.js.map +0 -1
- package/dist/plugin/adapter.d.ts.map +0 -1
- package/dist/plugin/adapter.js.map +0 -1
- package/dist/plugin/build-config.d.ts.map +0 -1
- package/dist/plugin/build-config.js.map +0 -1
- package/dist/types/config.d.ts.map +0 -1
- package/dist/types/config.js.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/utils/asset-collection.d.ts.map +0 -1
- package/dist/utils/asset-collection.js.map +0 -1
- package/dist/utils/build-detection.d.ts.map +0 -1
- package/dist/utils/build-detection.js.map +0 -1
- package/dist/utils/config.d.ts.map +0 -1
- package/dist/utils/config.js.map +0 -1
- package/dist/utils/download-template.d.ts.map +0 -1
- package/dist/utils/download-template.js.map +0 -1
- package/dist/utils/env-management.d.ts.map +0 -1
- package/dist/utils/env-management.js.map +0 -1
- package/dist/utils/format.d.ts.map +0 -1
- package/dist/utils/format.js.map +0 -1
- package/dist/utils/formatter.d.ts.map +0 -1
- package/dist/utils/formatter.js.map +0 -1
- package/dist/utils/git.d.ts.map +0 -1
- package/dist/utils/git.js.map +0 -1
- package/dist/utils/is-debug.d.ts.map +0 -1
- package/dist/utils/is-debug.js.map +0 -1
- package/dist/utils/lambda-config.d.ts.map +0 -1
- package/dist/utils/lambda-config.js.map +0 -1
- package/dist/utils/log.d.ts.map +0 -1
- package/dist/utils/log.js.map +0 -1
- package/dist/utils/messages.d.ts.map +0 -1
- package/dist/utils/messages.js.map +0 -1
- package/dist/utils/package-manager.d.ts.map +0 -1
- package/dist/utils/package-manager.js.map +0 -1
- package/dist/utils/payload-config-ast.d.ts.map +0 -1
- package/dist/utils/payload-config-ast.js.map +0 -1
- package/dist/utils/payload-config-finder.d.ts.map +0 -1
- package/dist/utils/payload-config-finder.js.map +0 -1
- package/dist/utils/payload-config-modifier.d.ts.map +0 -1
- package/dist/utils/payload-config-modifier.js.map +0 -1
- package/dist/utils/payload-package-check.d.ts.map +0 -1
- package/dist/utils/payload-package-check.js.map +0 -1
- package/dist/utils/project.d.ts.map +0 -1
- package/dist/utils/project.js.map +0 -1
- package/dist/utils/s3-upload.d.ts.map +0 -1
- package/dist/utils/s3-upload.js.map +0 -1
- package/dist/utils/token-display.d.ts.map +0 -1
- package/dist/utils/token-display.js.map +0 -1
- package/dist/utils/typescript-validator.d.ts.map +0 -1
- package/dist/utils/typescript-validator.js.map +0 -1
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The v1 server stores richText as a serialized JSON string, so stringify on
|
|
3
|
+
* write and parse on read. A localized richText is a per-locale map, serialized
|
|
4
|
+
* and parsed per entry (not as one blob).
|
|
5
|
+
*/ function isPlainObject(value) {
|
|
6
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
7
|
+
}
|
|
8
|
+
function richTextLeafToWire(value) {
|
|
9
|
+
if (value === null || value === undefined || typeof value === 'string') {
|
|
10
|
+
return value;
|
|
11
|
+
}
|
|
12
|
+
return JSON.stringify(value);
|
|
13
|
+
}
|
|
14
|
+
export function encodeRichTextForWrite(field, value) {
|
|
15
|
+
if (field.type !== 'richText' || value === null || value === undefined) {
|
|
16
|
+
return value;
|
|
17
|
+
}
|
|
18
|
+
if ('localized' in field && field.localized && isPlainObject(value)) {
|
|
19
|
+
const result = {};
|
|
20
|
+
for (const [locale, localeValue] of Object.entries(value)){
|
|
21
|
+
result[locale] = richTextLeafToWire(localeValue);
|
|
22
|
+
}
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
return richTextLeafToWire(value);
|
|
26
|
+
}
|
|
27
|
+
function richTextLeafFromWire(value, onError) {
|
|
28
|
+
if (typeof value !== 'string') {
|
|
29
|
+
return value;
|
|
30
|
+
}
|
|
31
|
+
try {
|
|
32
|
+
return JSON.parse(value);
|
|
33
|
+
} catch (error) {
|
|
34
|
+
onError(error);
|
|
35
|
+
return value;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export function decodeRichTextFromRead(field, value, payload, fieldPath, collectionSlug) {
|
|
39
|
+
if (field.type !== 'richText' || value === null || value === undefined) {
|
|
40
|
+
return value;
|
|
41
|
+
}
|
|
42
|
+
const onError = (error)=>{
|
|
43
|
+
payload.logger.warn({
|
|
44
|
+
err: error instanceof Error ? error : new Error(String(error)),
|
|
45
|
+
msg: `Failed to parse richtext field '${fieldPath}' in collection '${collectionSlug}'`
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
if ('localized' in field && field.localized && isPlainObject(value)) {
|
|
49
|
+
const result = {};
|
|
50
|
+
for (const [locale, localeValue] of Object.entries(value)){
|
|
51
|
+
result[locale] = richTextLeafFromWire(localeValue, onError);
|
|
52
|
+
}
|
|
53
|
+
return result;
|
|
54
|
+
}
|
|
55
|
+
return richTextLeafFromWire(value, onError);
|
|
56
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { FlattenedField, SanitizedConfig } from 'payload';
|
|
2
|
+
/**
|
|
3
|
+
* Strips fields from data that are not defined in the schema or are invalid.
|
|
4
|
+
*
|
|
5
|
+
* This function was copied from the MongoDB adapter's implementation:
|
|
6
|
+
* @see packages/db-mongodb/src/utilities/transform.ts (stripFields function)
|
|
7
|
+
*
|
|
8
|
+
* @description
|
|
9
|
+
* This utility performs deep sanitization of document data by:
|
|
10
|
+
* 1. **Removing undefined fields**: Strips any field not present in the collection's schema
|
|
11
|
+
* (e.g., sensitive fields like `password`, `apiKey`, or any extra fields not in config)
|
|
12
|
+
* 2. **Removing invalid locales**: Deletes locale keys that don't exist in `config.localization.localeCodes`
|
|
13
|
+
* (e.g., if data contains `{ "es-MX": "..." }` but only `"en"` is configured)
|
|
14
|
+
* 3. **Removing invalid blocks**: Filters out blocks with unknown `blockType` values
|
|
15
|
+
* (prevents data corruption from blocks that don't exist in the schema)
|
|
16
|
+
* 4. **Recursive sanitization**: Processes nested structures (arrays, groups, blocks, localized fields)
|
|
17
|
+
* to ensure deep data integrity
|
|
18
|
+
*
|
|
19
|
+
* @remarks
|
|
20
|
+
* Unlike MongoDB's adapter which uses Mongoose schemas with `strict: true` (rejecting extra fields
|
|
21
|
+
* on write), Content API uses flexible JSONB storage that accepts any fields. Therefore, this
|
|
22
|
+
* function is called on **both read and write operations** to ensure data consistency.
|
|
23
|
+
*
|
|
24
|
+
* The MongoDB adapter also supports an `allowAdditionalKeys` option that allows reading/writing
|
|
25
|
+
* fields not in the schema. For now, Content API does not support this feature - we always
|
|
26
|
+
* sanitize data. If users request this functionality in the future, we can consider adding it.
|
|
27
|
+
*
|
|
28
|
+
* @todo
|
|
29
|
+
* 1. Consider moving this utility to `payload/shared` so both MongoDB and Content API adapters
|
|
30
|
+
* can use the same implementation, reducing code duplication and maintenance burden.
|
|
31
|
+
*
|
|
32
|
+
* 2. Performance optimization: This function iterates through all fields recursively.
|
|
33
|
+
* The `dataToContentAPI` and `dataFromContentAPI` functions in
|
|
34
|
+
* `packages/figma/src/db-content-api/utilities/data.ts` also iterate through fields
|
|
35
|
+
* to transform richText (object ↔ JSON string), custom IDs (number ↔ string), and dates.
|
|
36
|
+
* Consider combining both traversals into a single abstraction to avoid iterating twice.
|
|
37
|
+
*
|
|
38
|
+
* 3. Feature parity: MongoDB adapter has `allowAdditionalKeys` option. We currently always
|
|
39
|
+
* strip additional keys, but could add this as a configurable option if users need it.
|
|
40
|
+
*/
|
|
41
|
+
export declare const stripFields: ({ config, data, fields, parentIsLocalized, reservedKeys, }: {
|
|
42
|
+
config: SanitizedConfig;
|
|
43
|
+
data: any;
|
|
44
|
+
fields: FlattenedField[];
|
|
45
|
+
parentIsLocalized?: boolean;
|
|
46
|
+
reservedKeys?: string[];
|
|
47
|
+
}) => void;
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { fieldShouldBeLocalized } from 'payload/shared';
|
|
2
|
+
import { resolveFlattenedBlock } from '../resolveBlocks.js';
|
|
3
|
+
/**
|
|
4
|
+
* Strips fields from data that are not defined in the schema or are invalid.
|
|
5
|
+
*
|
|
6
|
+
* This function was copied from the MongoDB adapter's implementation:
|
|
7
|
+
* @see packages/db-mongodb/src/utilities/transform.ts (stripFields function)
|
|
8
|
+
*
|
|
9
|
+
* @description
|
|
10
|
+
* This utility performs deep sanitization of document data by:
|
|
11
|
+
* 1. **Removing undefined fields**: Strips any field not present in the collection's schema
|
|
12
|
+
* (e.g., sensitive fields like `password`, `apiKey`, or any extra fields not in config)
|
|
13
|
+
* 2. **Removing invalid locales**: Deletes locale keys that don't exist in `config.localization.localeCodes`
|
|
14
|
+
* (e.g., if data contains `{ "es-MX": "..." }` but only `"en"` is configured)
|
|
15
|
+
* 3. **Removing invalid blocks**: Filters out blocks with unknown `blockType` values
|
|
16
|
+
* (prevents data corruption from blocks that don't exist in the schema)
|
|
17
|
+
* 4. **Recursive sanitization**: Processes nested structures (arrays, groups, blocks, localized fields)
|
|
18
|
+
* to ensure deep data integrity
|
|
19
|
+
*
|
|
20
|
+
* @remarks
|
|
21
|
+
* Unlike MongoDB's adapter which uses Mongoose schemas with `strict: true` (rejecting extra fields
|
|
22
|
+
* on write), Content API uses flexible JSONB storage that accepts any fields. Therefore, this
|
|
23
|
+
* function is called on **both read and write operations** to ensure data consistency.
|
|
24
|
+
*
|
|
25
|
+
* The MongoDB adapter also supports an `allowAdditionalKeys` option that allows reading/writing
|
|
26
|
+
* fields not in the schema. For now, Content API does not support this feature - we always
|
|
27
|
+
* sanitize data. If users request this functionality in the future, we can consider adding it.
|
|
28
|
+
*
|
|
29
|
+
* @todo
|
|
30
|
+
* 1. Consider moving this utility to `payload/shared` so both MongoDB and Content API adapters
|
|
31
|
+
* can use the same implementation, reducing code duplication and maintenance burden.
|
|
32
|
+
*
|
|
33
|
+
* 2. Performance optimization: This function iterates through all fields recursively.
|
|
34
|
+
* The `dataToContentAPI` and `dataFromContentAPI` functions in
|
|
35
|
+
* `packages/figma/src/db-content-api/utilities/data.ts` also iterate through fields
|
|
36
|
+
* to transform richText (object ↔ JSON string), custom IDs (number ↔ string), and dates.
|
|
37
|
+
* Consider combining both traversals into a single abstraction to avoid iterating twice.
|
|
38
|
+
*
|
|
39
|
+
* 3. Feature parity: MongoDB adapter has `allowAdditionalKeys` option. We currently always
|
|
40
|
+
* strip additional keys, but could add this as a configurable option if users need it.
|
|
41
|
+
*/ export const stripFields = ({ config, data, fields, parentIsLocalized = false, reservedKeys = [] })=>{
|
|
42
|
+
for(const k in data){
|
|
43
|
+
if (!fields.some((field)=>field.name === k) && !reservedKeys.includes(k)) {
|
|
44
|
+
delete data[k];
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
for (const field of fields){
|
|
48
|
+
reservedKeys = [];
|
|
49
|
+
const fieldData = data[field.name];
|
|
50
|
+
if (!fieldData || typeof fieldData !== 'object') {
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
const shouldLocalizeField = fieldShouldBeLocalized({
|
|
54
|
+
field,
|
|
55
|
+
parentIsLocalized
|
|
56
|
+
});
|
|
57
|
+
if (field.type === 'blocks') {
|
|
58
|
+
reservedKeys.push('blockType');
|
|
59
|
+
}
|
|
60
|
+
if ('flattenedFields' in field || 'blocks' in field) {
|
|
61
|
+
if (shouldLocalizeField && config.localization) {
|
|
62
|
+
for(const localeKey in fieldData){
|
|
63
|
+
if (!config.localization.localeCodes.some((code)=>code === localeKey)) {
|
|
64
|
+
delete fieldData[localeKey];
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
const localeData = fieldData[localeKey];
|
|
68
|
+
if (!localeData || typeof localeData !== 'object') {
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
if (field.type === 'array' || field.type === 'blocks') {
|
|
72
|
+
if (!Array.isArray(localeData)) {
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
let hasNull = false;
|
|
76
|
+
for(let i = 0; i < localeData.length; i++){
|
|
77
|
+
const data = localeData[i];
|
|
78
|
+
let fields = null;
|
|
79
|
+
if (field.type === 'array') {
|
|
80
|
+
fields = field.flattenedFields;
|
|
81
|
+
} else {
|
|
82
|
+
const maybeBlock = resolveFlattenedBlock({
|
|
83
|
+
blocks: field.blocks,
|
|
84
|
+
blockType: data.blockType,
|
|
85
|
+
configBlocks: config.blocks
|
|
86
|
+
});
|
|
87
|
+
if (maybeBlock) {
|
|
88
|
+
fields = maybeBlock.flattenedFields;
|
|
89
|
+
} else {
|
|
90
|
+
localeData[i] = null;
|
|
91
|
+
hasNull = true;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (!fields) {
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
stripFields({
|
|
98
|
+
config,
|
|
99
|
+
data,
|
|
100
|
+
fields,
|
|
101
|
+
parentIsLocalized: parentIsLocalized || field.localized,
|
|
102
|
+
reservedKeys
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
if (hasNull) {
|
|
106
|
+
fieldData[localeKey] = localeData.filter(Boolean);
|
|
107
|
+
}
|
|
108
|
+
continue;
|
|
109
|
+
} else {
|
|
110
|
+
stripFields({
|
|
111
|
+
config,
|
|
112
|
+
data: localeData,
|
|
113
|
+
fields: field.flattenedFields,
|
|
114
|
+
parentIsLocalized: parentIsLocalized || field.localized,
|
|
115
|
+
reservedKeys
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
if (field.type === 'array' || field.type === 'blocks') {
|
|
122
|
+
if (!Array.isArray(fieldData)) {
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
let hasNull = false;
|
|
126
|
+
for(let i = 0; i < fieldData.length; i++){
|
|
127
|
+
const data = fieldData[i];
|
|
128
|
+
let fields = null;
|
|
129
|
+
if (field.type === 'array') {
|
|
130
|
+
fields = field.flattenedFields;
|
|
131
|
+
} else {
|
|
132
|
+
const maybeBlock = resolveFlattenedBlock({
|
|
133
|
+
blocks: field.blocks,
|
|
134
|
+
blockType: data.blockType,
|
|
135
|
+
configBlocks: config.blocks
|
|
136
|
+
});
|
|
137
|
+
if (maybeBlock) {
|
|
138
|
+
fields = maybeBlock.flattenedFields;
|
|
139
|
+
} else {
|
|
140
|
+
fieldData[i] = null;
|
|
141
|
+
hasNull = true;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
if (!fields) {
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
stripFields({
|
|
148
|
+
config,
|
|
149
|
+
data,
|
|
150
|
+
fields,
|
|
151
|
+
parentIsLocalized: parentIsLocalized || field.localized,
|
|
152
|
+
reservedKeys
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
if (hasNull) {
|
|
156
|
+
data[field.name] = fieldData.filter(Boolean);
|
|
157
|
+
}
|
|
158
|
+
continue;
|
|
159
|
+
} else {
|
|
160
|
+
stripFields({
|
|
161
|
+
config,
|
|
162
|
+
data: fieldData,
|
|
163
|
+
fields: field.flattenedFields,
|
|
164
|
+
parentIsLocalized: parentIsLocalized || field.localized,
|
|
165
|
+
reservedKeys
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transform publishedLocale to localizeStatus format
|
|
3
|
+
*
|
|
4
|
+
* publishedLocale is a legacy API that is going to be removed in Payload v4 in favor of localizeStatus.
|
|
5
|
+
* The db-adapter transforms publishedLocale here so Content API doesn't need to know about it.
|
|
6
|
+
*/
|
|
7
|
+
type VersionData = Record<string, unknown>;
|
|
8
|
+
/**
|
|
9
|
+
* Transforms version data to use localizeStatus format
|
|
10
|
+
*
|
|
11
|
+
* If `publishedLocale` is provided and `_status` is a string, transforms to object format.
|
|
12
|
+
* If `_status` is already an object, leaves it unchanged.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* // Input (old format):
|
|
16
|
+
* { _status: 'published', text: 'Hello' }, publishedLocale: 'en'
|
|
17
|
+
*
|
|
18
|
+
* // Output (new format):
|
|
19
|
+
* { _status: { en: 'published' }, text: 'Hello' }
|
|
20
|
+
*/
|
|
21
|
+
export declare function transformToLocalizeStatus(versionData: VersionData, publishedLocale?: string): VersionData;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transform publishedLocale to localizeStatus format
|
|
3
|
+
*
|
|
4
|
+
* publishedLocale is a legacy API that is going to be removed in Payload v4 in favor of localizeStatus.
|
|
5
|
+
* The db-adapter transforms publishedLocale here so Content API doesn't need to know about it.
|
|
6
|
+
*/ /**
|
|
7
|
+
* Transforms version data to use localizeStatus format
|
|
8
|
+
*
|
|
9
|
+
* If `publishedLocale` is provided and `_status` is a string, transforms to object format.
|
|
10
|
+
* If `_status` is already an object, leaves it unchanged.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* // Input (old format):
|
|
14
|
+
* { _status: 'published', text: 'Hello' }, publishedLocale: 'en'
|
|
15
|
+
*
|
|
16
|
+
* // Output (new format):
|
|
17
|
+
* { _status: { en: 'published' }, text: 'Hello' }
|
|
18
|
+
*/ export function transformToLocalizeStatus(versionData, publishedLocale) {
|
|
19
|
+
// No publishedLocale provided - no transformation needed
|
|
20
|
+
if (!publishedLocale) {
|
|
21
|
+
return versionData;
|
|
22
|
+
}
|
|
23
|
+
const status = versionData._status;
|
|
24
|
+
// If _status is already an object (localizeStatus format), return as-is
|
|
25
|
+
if (typeof status === 'object' && status !== null) {
|
|
26
|
+
return versionData;
|
|
27
|
+
}
|
|
28
|
+
// Transform: publishedLocale + string status → object status
|
|
29
|
+
if (typeof status === 'string') {
|
|
30
|
+
// Only the specified locale gets the status, others remain undefined
|
|
31
|
+
// (Content API / Payload will handle merging with existing locale statuses)
|
|
32
|
+
return {
|
|
33
|
+
...versionData,
|
|
34
|
+
_status: {
|
|
35
|
+
[publishedLocale]: status
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
return versionData;
|
|
40
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { traverseFields } from 'payload';
|
|
2
|
+
import { valueIsValueWithRelation } from 'payload/shared';
|
|
3
|
+
import { RELATIONSHIP_ATOMIC_OPERATORS, unwrapAtomicOperation } from './atomicOperations.js';
|
|
4
|
+
import { resolveFieldLocalization } from './resolveFieldLocalization.js';
|
|
5
|
+
const UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
6
|
+
function collectRelationshipValues({ data, fields }) {
|
|
7
|
+
const relationships = [];
|
|
8
|
+
const callback = ({ field: declaredField, parentIsLocalized, ref })=>{
|
|
9
|
+
if (!('name' in declaredField) || !declaredField.name) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
if (declaredField.type !== 'relationship' && declaredField.type !== 'upload') {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
if (!ref || typeof ref !== 'object') {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
// Only a field whose locale keys were not absorbed by a localized ancestor
|
|
19
|
+
// holds a locale map; an absorbed one holds the relationship value directly.
|
|
20
|
+
const field = resolveFieldLocalization({
|
|
21
|
+
field: declaredField,
|
|
22
|
+
isAbsorbed: parentIsLocalized
|
|
23
|
+
});
|
|
24
|
+
const rawValue = ref[field.name];
|
|
25
|
+
if (rawValue == null || rawValue === '') {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
// For localized fields, the value is a locale map (e.g. { en: "uuid", fr: "uuid" }).
|
|
29
|
+
// Iterate locale values instead of treating the map as an ID.
|
|
30
|
+
if ('localized' in field && field.localized) {
|
|
31
|
+
if (typeof rawValue === 'object' && !Array.isArray(rawValue)) {
|
|
32
|
+
for (const localeValue of Object.values(rawValue)){
|
|
33
|
+
if (localeValue != null && localeValue !== '') {
|
|
34
|
+
parseRelationshipValues(localeValue, field.relationTo, relationships);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
parseRelationshipValues(rawValue, field.relationTo, relationships);
|
|
41
|
+
};
|
|
42
|
+
traverseFields({
|
|
43
|
+
callback,
|
|
44
|
+
fields,
|
|
45
|
+
fillEmpty: false,
|
|
46
|
+
ref: data
|
|
47
|
+
});
|
|
48
|
+
return relationships;
|
|
49
|
+
}
|
|
50
|
+
function parseRelationshipValues(rawValue, relationTo, relationships) {
|
|
51
|
+
const value = unwrapAtomicOperation(rawValue, RELATIONSHIP_ATOMIC_OPERATORS);
|
|
52
|
+
if (Array.isArray(relationTo)) {
|
|
53
|
+
// Polymorphic (single or hasMany): value is { relationTo, value } or array of them
|
|
54
|
+
const values = Array.isArray(value) ? value : [
|
|
55
|
+
value
|
|
56
|
+
];
|
|
57
|
+
for (const v of values){
|
|
58
|
+
if (valueIsValueWithRelation(v) && v.value != null && v.value !== '') {
|
|
59
|
+
relationships.push({
|
|
60
|
+
collection: v.relationTo,
|
|
61
|
+
value: v.value
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
} else {
|
|
66
|
+
// Non-polymorphic (single or hasMany): value is a bare ID or array of IDs
|
|
67
|
+
const values = Array.isArray(value) ? value : [
|
|
68
|
+
value
|
|
69
|
+
];
|
|
70
|
+
for (const v of values){
|
|
71
|
+
if (v != null && v !== '') {
|
|
72
|
+
relationships.push({
|
|
73
|
+
collection: relationTo,
|
|
74
|
+
value: v
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
function isValidId(value, customIDType) {
|
|
81
|
+
if (customIDType === 'number') {
|
|
82
|
+
const num = typeof value === 'number' ? value : typeof value === 'string' ? Number(value) : NaN;
|
|
83
|
+
return Number.isFinite(num);
|
|
84
|
+
}
|
|
85
|
+
if (customIDType === 'text') {
|
|
86
|
+
return typeof value === 'string' && value.length > 0;
|
|
87
|
+
}
|
|
88
|
+
return typeof value === 'string' && UUID_REGEX.test(value);
|
|
89
|
+
}
|
|
90
|
+
export function validateRelationshipIds({ collectionSlug, data, payload }) {
|
|
91
|
+
const isGlobal = collectionSlug.startsWith('_global-');
|
|
92
|
+
const actualSlug = isGlobal ? collectionSlug.substring(8) : collectionSlug;
|
|
93
|
+
const config = isGlobal ? payload.config.globals?.find((g)=>g.slug === actualSlug) : payload.config.collections.find((c)=>c.slug === actualSlug);
|
|
94
|
+
if (!config?.fields) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
const relationships = collectRelationshipValues({
|
|
98
|
+
data,
|
|
99
|
+
fields: config.fields
|
|
100
|
+
});
|
|
101
|
+
for (const { collection, value } of relationships){
|
|
102
|
+
const customIDType = payload.collections?.[collection]?.customIDType;
|
|
103
|
+
if (!isValidId(value, customIDType)) {
|
|
104
|
+
throw new Error(`Invalid relationship ID "${String(value)}" for collection "${collection}". Expected ${customIDType === 'number' ? 'a number' : customIDType === 'text' ? 'a non-empty string' : 'a valid UUID'}.`);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { JoinQuery, Payload } from 'payload';
|
|
2
|
+
import type { components } from '../generated/content-api-types.js';
|
|
3
|
+
type ContentAPIJoin = components['schemas']['JoinClauseV1'][number];
|
|
4
|
+
/**
|
|
5
|
+
* Convert Payload's JoinQuery to Content API's join format.
|
|
6
|
+
*
|
|
7
|
+
* ## Content API Join Limitations
|
|
8
|
+
*
|
|
9
|
+
* The following Payload join features are NOT YET supported by Content API:
|
|
10
|
+
*
|
|
11
|
+
* 1. **hasMany relationships** - Content API's join uses `data#>'{path}'#>>'{}'` to extract
|
|
12
|
+
* a single ID. HasMany relationships store arrays `["id1", "id2"]` which can't match.
|
|
13
|
+
*
|
|
14
|
+
* 2. **Array field relationships** - `on: 'array.category'` expects iteration over array
|
|
15
|
+
* elements, but Content API treats the path as a single JSONB extraction.
|
|
16
|
+
*
|
|
17
|
+
* 3. **Polymorphic relationships** - Stored as `{ relationTo, value }` objects, but
|
|
18
|
+
* Content API expects a simple ID string.
|
|
19
|
+
*
|
|
20
|
+
* Note: "Where querying through joins" (e.g., `where: { 'relatedPosts.title': { equals: 'x' } }`)
|
|
21
|
+
* is a separate Payload feature that filters documents based on joined data. This is NOT
|
|
22
|
+
* a join feature but a where clause feature, and would need separate Content API support.
|
|
23
|
+
*
|
|
24
|
+
* Payload's JoinQuery format (at runtime):
|
|
25
|
+
* {
|
|
26
|
+
* 'group.relatedPosts': { // joinPath - where results go in the document
|
|
27
|
+
* sort: '-title',
|
|
28
|
+
* limit: 10,
|
|
29
|
+
* page: 2, // page-based pagination
|
|
30
|
+
* where: { ... }, // Payload where format
|
|
31
|
+
* count: true
|
|
32
|
+
* }
|
|
33
|
+
* }
|
|
34
|
+
*
|
|
35
|
+
* Content API's v1 join format:
|
|
36
|
+
* [{
|
|
37
|
+
* path: 'group.relatedPosts', // where to put results
|
|
38
|
+
* count: false,
|
|
39
|
+
* where: { ... }, // Content API where format
|
|
40
|
+
* sort: '-title',
|
|
41
|
+
* limit: 10,
|
|
42
|
+
* page: 2
|
|
43
|
+
* }]
|
|
44
|
+
*
|
|
45
|
+
* v1 resolves the joined collection and key from the document schema, so the
|
|
46
|
+
* adapter no longer emits collectionId/on. The collection config is still read
|
|
47
|
+
* to resolve default limit and sort for each join path.
|
|
48
|
+
*/
|
|
49
|
+
export declare function convertPayloadJoinsToContentAPI(payload: Payload, collectionSlug: string, joins: false | JoinQuery | undefined): ContentAPIJoin[] | undefined;
|
|
50
|
+
export {};
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { addFallbackSort } from '../temp-utilities/sorting.js';
|
|
2
|
+
import { convertPayloadWhereToContentAPI } from './where.js';
|
|
3
|
+
/**
|
|
4
|
+
* Convert Payload's JoinQuery to Content API's join format.
|
|
5
|
+
*
|
|
6
|
+
* ## Content API Join Limitations
|
|
7
|
+
*
|
|
8
|
+
* The following Payload join features are NOT YET supported by Content API:
|
|
9
|
+
*
|
|
10
|
+
* 1. **hasMany relationships** - Content API's join uses `data#>'{path}'#>>'{}'` to extract
|
|
11
|
+
* a single ID. HasMany relationships store arrays `["id1", "id2"]` which can't match.
|
|
12
|
+
*
|
|
13
|
+
* 2. **Array field relationships** - `on: 'array.category'` expects iteration over array
|
|
14
|
+
* elements, but Content API treats the path as a single JSONB extraction.
|
|
15
|
+
*
|
|
16
|
+
* 3. **Polymorphic relationships** - Stored as `{ relationTo, value }` objects, but
|
|
17
|
+
* Content API expects a simple ID string.
|
|
18
|
+
*
|
|
19
|
+
* Note: "Where querying through joins" (e.g., `where: { 'relatedPosts.title': { equals: 'x' } }`)
|
|
20
|
+
* is a separate Payload feature that filters documents based on joined data. This is NOT
|
|
21
|
+
* a join feature but a where clause feature, and would need separate Content API support.
|
|
22
|
+
*
|
|
23
|
+
* Payload's JoinQuery format (at runtime):
|
|
24
|
+
* {
|
|
25
|
+
* 'group.relatedPosts': { // joinPath - where results go in the document
|
|
26
|
+
* sort: '-title',
|
|
27
|
+
* limit: 10,
|
|
28
|
+
* page: 2, // page-based pagination
|
|
29
|
+
* where: { ... }, // Payload where format
|
|
30
|
+
* count: true
|
|
31
|
+
* }
|
|
32
|
+
* }
|
|
33
|
+
*
|
|
34
|
+
* Content API's v1 join format:
|
|
35
|
+
* [{
|
|
36
|
+
* path: 'group.relatedPosts', // where to put results
|
|
37
|
+
* count: false,
|
|
38
|
+
* where: { ... }, // Content API where format
|
|
39
|
+
* sort: '-title',
|
|
40
|
+
* limit: 10,
|
|
41
|
+
* page: 2
|
|
42
|
+
* }]
|
|
43
|
+
*
|
|
44
|
+
* v1 resolves the joined collection and key from the document schema, so the
|
|
45
|
+
* adapter no longer emits collectionId/on. The collection config is still read
|
|
46
|
+
* to resolve default limit and sort for each join path.
|
|
47
|
+
*/ export function convertPayloadJoinsToContentAPI(payload, collectionSlug, joins) {
|
|
48
|
+
const collectionConfig = payload.config.collections.find((c)=>c.slug === collectionSlug);
|
|
49
|
+
if (!collectionConfig) {
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
// joins === false means explicitly disable all joins
|
|
53
|
+
// joins === undefined means use defaults (no custom query params)
|
|
54
|
+
if (joins === false || !joins) {
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
const result = [];
|
|
58
|
+
// Iterate through all join paths in the query
|
|
59
|
+
for (const [joinPath, joinQueryValue] of Object.entries(joins)){
|
|
60
|
+
// joinQuery === false means skip this specific join
|
|
61
|
+
if (joinQueryValue === false) {
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
// Normalize undefined/empty to empty object
|
|
65
|
+
const joinQuery = joinQueryValue ?? {};
|
|
66
|
+
// Find the SanitizedJoin config for this joinPath
|
|
67
|
+
// SanitizedJoins is indexed by the collection being joined FROM
|
|
68
|
+
let foundJoin;
|
|
69
|
+
// Search through all collections in the joins config
|
|
70
|
+
for (const [collectionSlug, sanitizedJoins] of Object.entries(collectionConfig.joins)){
|
|
71
|
+
for (const sanitizedJoin of sanitizedJoins){
|
|
72
|
+
if (sanitizedJoin.joinPath === joinPath) {
|
|
73
|
+
foundJoin = {
|
|
74
|
+
collectionSlug,
|
|
75
|
+
defaultLimit: sanitizedJoin.field.defaultLimit,
|
|
76
|
+
defaultSort: sanitizedJoin.field.defaultSort
|
|
77
|
+
};
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
if (foundJoin) {
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
// Also check polymorphic joins
|
|
86
|
+
if (!foundJoin) {
|
|
87
|
+
for (const sanitizedJoin of collectionConfig.polymorphicJoins){
|
|
88
|
+
if (sanitizedJoin.joinPath === joinPath) {
|
|
89
|
+
foundJoin = {
|
|
90
|
+
collectionSlug: sanitizedJoin.field.collection,
|
|
91
|
+
defaultSort: sanitizedJoin.field.defaultSort
|
|
92
|
+
};
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (!foundJoin) {
|
|
98
|
+
payload.logger.warn(`Join path '${joinPath}' not found in collection config for '${collectionConfig.slug}'`);
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
// Fall back to the default limit if not specified in the query
|
|
102
|
+
const effectiveLimit = joinQuery.limit ?? foundJoin.defaultLimit;
|
|
103
|
+
// Add fallback sort for the joined collection
|
|
104
|
+
const sortWithFallback = addFallbackSort(joinQuery.sort, payload, foundJoin.collectionSlug, foundJoin.defaultSort);
|
|
105
|
+
const contentAPIJoin = {
|
|
106
|
+
count: joinQuery.count ?? false,
|
|
107
|
+
path: joinPath,
|
|
108
|
+
...effectiveLimit !== undefined && {
|
|
109
|
+
limit: effectiveLimit
|
|
110
|
+
},
|
|
111
|
+
...joinQuery.page && {
|
|
112
|
+
page: joinQuery.page
|
|
113
|
+
},
|
|
114
|
+
...sortWithFallback && {
|
|
115
|
+
sort: sortWithFallback
|
|
116
|
+
},
|
|
117
|
+
...joinQuery.where && {
|
|
118
|
+
where: convertPayloadWhereToContentAPI(joinQuery.where)
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
result.push(contentAPIJoin);
|
|
122
|
+
}
|
|
123
|
+
return result.length > 0 ? result : undefined;
|
|
124
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Payload } from 'payload';
|
|
2
|
+
/**
|
|
3
|
+
* Determines what locale to send to Content API based on request locale value
|
|
4
|
+
* and config's defaultLocale.
|
|
5
|
+
*
|
|
6
|
+
* If no locale is provided, falls back to the default locale from config.
|
|
7
|
+
* Returns undefined for 'all' and '*' (special Payload values for returning all locales).
|
|
8
|
+
*/
|
|
9
|
+
export declare function addFallbackLocale(locale: null | string | undefined, payload: Payload): string | undefined;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Determines what locale to send to Content API based on request locale value
|
|
3
|
+
* and config's defaultLocale.
|
|
4
|
+
*
|
|
5
|
+
* If no locale is provided, falls back to the default locale from config.
|
|
6
|
+
* Returns undefined for 'all' and '*' (special Payload values for returning all locales).
|
|
7
|
+
*/ export function addFallbackLocale(locale, payload) {
|
|
8
|
+
const defaultLocale = payload.config.localization ? payload.config.localization.defaultLocale : undefined;
|
|
9
|
+
if (locale) {
|
|
10
|
+
// 'all' and '*' are special Payload values meaning "return all locales" - don't send to Content API
|
|
11
|
+
if (locale === 'all' || locale === '*') {
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
14
|
+
return locale;
|
|
15
|
+
} else if (defaultLocale) {
|
|
16
|
+
return defaultLocale;
|
|
17
|
+
}
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Payload, Where } from 'payload';
|
|
2
|
+
/**
|
|
3
|
+
* Normalizes a Where clause by inserting locale keys into paths that traverse
|
|
4
|
+
* localized array/blocks fields without an explicit locale.
|
|
5
|
+
*
|
|
6
|
+
* Only runs when a locale is provided and the collection has localized array/blocks fields.
|
|
7
|
+
* Returns the original where clause if no transformation is needed.
|
|
8
|
+
*/
|
|
9
|
+
export declare function normalizeLocaleInWhere(where: undefined | Where, payload: Payload, collectionSlug: string, locale: string | undefined): undefined | Where;
|