@payloadcms/figma 0.0.1-alpha.7 → 0.0.1-alpha.70
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 -6
- package/dist/api/control-plane.js +181 -72
- package/dist/api/figma-api.d.ts +22 -1
- package/dist/api/figma-api.js +78 -25
- package/dist/auth/callback-server.d.ts +19 -7
- package/dist/auth/callback-server.js +72 -30
- package/dist/auth/credentials.d.ts +21 -0
- package/dist/auth/credentials.js +21 -0
- package/dist/auth/crypto-utils.d.ts +28 -0
- package/dist/auth/crypto-utils.js +132 -21
- package/dist/auth/jwt-validator.d.ts +2 -1
- package/dist/auth/jwt-validator.js +2 -2
- package/dist/auth/oauth-flow.d.ts +19 -3
- package/dist/auth/oauth-flow.js +77 -22
- package/dist/auth/project-token.d.ts +32 -16
- package/dist/auth/project-token.js +171 -65
- package/dist/auth/refresh.d.ts +2 -1
- package/dist/auth/refresh.js +25 -12
- package/dist/auth/token-store-migration.d.ts +58 -0
- package/dist/auth/token-store-migration.js +156 -0
- package/dist/auth/token-store.d.ts +63 -97
- package/dist/auth/token-store.js +405 -122
- package/dist/auth/types.d.ts +35 -4
- package/dist/cli.js +93 -6
- package/dist/commands/bootstrap.d.ts +18 -0
- package/dist/commands/bootstrap.js +90 -0
- package/dist/commands/build-lambda-zip.d.ts +5 -0
- package/dist/commands/build-lambda-zip.js +19 -0
- package/dist/commands/debug.d.ts +8 -0
- package/dist/commands/debug.js +180 -0
- package/dist/commands/deploy.d.ts +9 -0
- package/dist/commands/deploy.js +180 -151
- package/dist/commands/dump-tokens.d.ts +12 -0
- package/dist/commands/dump-tokens.js +69 -0
- package/dist/commands/env.d.ts +13 -0
- package/dist/commands/env.js +88 -0
- package/dist/commands/init.d.ts +9 -5
- package/dist/commands/init.js +241 -148
- package/dist/commands/list-tokens.d.ts +3 -3
- package/dist/commands/list-tokens.js +24 -9
- package/dist/commands/login.d.ts +8 -1
- package/dist/commands/login.js +34 -16
- package/dist/commands/logout.d.ts +5 -4
- package/dist/commands/logout.js +77 -15
- package/dist/commands/upgrade.d.ts +5 -0
- package/dist/commands/upgrade.js +331 -0
- package/dist/config/oauth.d.ts +17 -11
- package/dist/config/oauth.js +38 -37
- package/dist/constants.d.ts +63 -18
- package/dist/constants.js +158 -18
- package/dist/db-content-api/generated/content-api-types.d.ts +3978 -0
- package/dist/db-content-api/generated/content-api-types.js +7 -0
- package/dist/db-content-api/index.d.ts +37 -0
- package/dist/db-content-api/index.js +923 -0
- package/dist/db-content-api/temp-utilities/slug.d.ts +2 -0
- package/dist/db-content-api/temp-utilities/slug.js +3 -0
- package/dist/db-content-api/temp-utilities/sorting.d.ts +3 -0
- package/dist/db-content-api/temp-utilities/sorting.js +39 -0
- package/dist/db-content-api/temp-utilities/types.d.ts +22 -0
- package/dist/db-content-api/temp-utilities/types.js +15 -0
- package/dist/db-content-api/temp-utilities/unwrapDocument.d.ts +39 -0
- package/dist/db-content-api/temp-utilities/unwrapDocument.js +64 -0
- package/dist/db-content-api/utilities/auth.d.ts +30 -0
- package/dist/db-content-api/utilities/auth.js +84 -0
- package/dist/db-content-api/utilities/data/applyDefaults.d.ts +7 -0
- package/dist/db-content-api/utilities/data/applyDefaults.js +75 -0
- package/dist/db-content-api/utilities/data/castFieldValue.d.ts +11 -0
- package/dist/db-content-api/utilities/data/castFieldValue.js +68 -0
- package/dist/db-content-api/utilities/data/index.d.ts +49 -0
- package/dist/db-content-api/utilities/data/index.js +301 -0
- package/dist/db-content-api/utilities/data/removeVirtualFields.d.ts +12 -0
- package/dist/db-content-api/utilities/data/removeVirtualFields.js +54 -0
- package/dist/db-content-api/utilities/data/stripFields.d.ts +48 -0
- package/dist/db-content-api/utilities/data/stripFields.js +195 -0
- package/dist/db-content-api/utilities/data/transformPublishedLocale.d.ts +23 -0
- package/dist/db-content-api/utilities/data/transformPublishedLocale.js +42 -0
- package/dist/db-content-api/utilities/data/validateRelationships.d.ts +7 -0
- package/dist/db-content-api/utilities/data/validateRelationships.js +102 -0
- package/dist/db-content-api/utilities/joins.d.ts +53 -0
- package/dist/db-content-api/utilities/joins.js +139 -0
- package/dist/db-content-api/utilities/locale/index.d.ts +10 -0
- package/dist/db-content-api/utilities/locale/index.js +21 -0
- package/dist/db-content-api/utilities/meta/buildLocalizedPaths.d.ts +11 -0
- package/dist/db-content-api/utilities/meta/buildLocalizedPaths.js +74 -0
- package/dist/db-content-api/utilities/meta/buildMeta.d.ts +42 -0
- package/dist/db-content-api/utilities/meta/buildMeta.js +41 -0
- package/dist/db-content-api/utilities/meta/buildPathTypes.d.ts +17 -0
- package/dist/db-content-api/utilities/meta/buildPathTypes.js +244 -0
- package/dist/db-content-api/utilities/meta/buildUniquePaths.d.ts +13 -0
- package/dist/db-content-api/utilities/meta/buildUniquePaths.js +62 -0
- package/dist/db-content-api/utilities/meta/normalizeLocaleInWhere.d.ts +10 -0
- package/dist/db-content-api/utilities/meta/normalizeLocaleInWhere.js +102 -0
- package/dist/db-content-api/utilities/where.d.ts +20 -0
- package/dist/db-content-api/utilities/where.js +108 -0
- package/dist/deploy/schedule-extract-plugin.d.ts +11 -0
- package/dist/deploy/schedule-extract-plugin.js +34 -0
- package/dist/endpoints/health.d.ts +3 -0
- package/dist/endpoints/health.js +11 -0
- package/dist/endpoints/schema.d.ts +3 -0
- package/dist/endpoints/schema.js +29 -0
- package/dist/exports/client.d.ts +3 -0
- package/dist/exports/client.js +3 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3 -1
- package/dist/lib/download-skill.d.ts +13 -0
- package/dist/lib/download-skill.js +79 -0
- package/dist/oauth/components/FigmaAvatar/index.d.ts +4 -0
- package/dist/oauth/components/FigmaAvatar/index.js +27 -0
- package/dist/oauth/components/FigmaAvatar/index.scss +12 -0
- package/dist/oauth/components/FigmaAvatarCell/index.d.ts +5 -0
- package/dist/oauth/components/FigmaAvatarCell/index.js +25 -0
- package/dist/oauth/components/FigmaAvatarCell/index.scss +5 -0
- package/dist/oauth/components/FigmaAvatarPlaceholder/index.d.ts +9 -0
- package/dist/oauth/components/FigmaAvatarPlaceholder/index.js +37 -0
- package/dist/oauth/components/FigmaAvatarPlaceholder/index.scss +28 -0
- package/dist/oauth/components/LoginButton/iframeAutoLogin.d.ts +82 -0
- package/dist/oauth/components/LoginButton/iframeAutoLogin.js +170 -0
- package/dist/oauth/components/LoginButton/index.js +144 -11
- package/dist/oauth/components/LoginButton/index.scss +75 -3
- package/dist/oauth/components/LogoutButton/index.js +19 -6
- package/dist/oauth/defaults.d.ts +3 -1
- package/dist/oauth/defaults.js +68 -10
- package/dist/oauth/endpoints/getLoginEndpoint.js +72 -77
- package/dist/oauth/endpoints/getLogoutEndpoint.js +7 -4
- package/dist/oauth/endpoints/getMetaEndpoint.js +18 -3
- package/dist/oauth/endpoints/getRedirectToLoginEndpoint.js +11 -2
- package/dist/oauth/index.js +27 -5
- package/dist/oauth/strategy/index.d.ts +0 -2
- package/dist/oauth/strategy/index.js +40 -17
- package/dist/oauth/types.d.ts +23 -6
- package/dist/oauth/utilities/establishSession.d.ts +23 -0
- package/dist/oauth/utilities/establishSession.js +82 -0
- package/dist/oauth/utilities/exchangeCodeForAccessToken.d.ts +24 -0
- package/dist/oauth/utilities/exchangeCodeForAccessToken.js +28 -0
- package/dist/oauth/utilities/figmaHostnames.d.ts +3 -0
- package/dist/oauth/utilities/figmaHostnames.js +26 -0
- package/dist/oauth/utilities/getAuthorizeURL.d.ts +65 -1
- package/dist/oauth/utilities/getAuthorizeURL.js +57 -2
- package/dist/oauth/utilities/isAbsoluteURL.d.ts +2 -0
- package/dist/oauth/utilities/isAbsoluteURL.js +3 -0
- package/dist/oauth/utilities/isDuplicateKeyError.d.ts +7 -0
- package/dist/oauth/utilities/isDuplicateKeyError.js +14 -0
- package/dist/oauth/utilities/refreshTokens.js +6 -3
- package/dist/plugin/auth-preflight.d.ts +8 -0
- package/dist/plugin/auth-preflight.js +20 -0
- package/dist/plugin/bootstrap-preflight.d.ts +23 -0
- package/dist/plugin/bootstrap-preflight.js +45 -0
- package/dist/plugin/build-config.d.ts +27 -15
- package/dist/plugin/build-config.js +327 -17
- package/dist/plugin/dev-cookie-names.d.ts +14 -0
- package/dist/plugin/dev-cookie-names.js +19 -0
- package/dist/storage-content-api/api-types.d.ts +168 -0
- package/dist/storage-content-api/api-types.js +6 -0
- package/dist/storage-content-api/client-uploads/ClientUploadHandler.d.ts +9 -0
- package/dist/storage-content-api/client-uploads/ClientUploadHandler.js +43 -0
- package/dist/storage-content-api/client-uploads/generateSignedURL.d.ts +13 -0
- package/dist/storage-content-api/client-uploads/generateSignedURL.js +39 -0
- package/dist/storage-content-api/client.d.ts +6 -0
- package/dist/storage-content-api/client.js +39 -0
- package/dist/storage-content-api/generateURL.d.ts +7 -0
- package/dist/storage-content-api/generateURL.js +8 -0
- package/dist/storage-content-api/handleDelete.d.ts +8 -0
- package/dist/storage-content-api/handleDelete.js +17 -0
- package/dist/storage-content-api/handleUpload.d.ts +11 -0
- package/dist/storage-content-api/handleUpload.js +144 -0
- package/dist/storage-content-api/index.d.ts +5 -0
- package/dist/storage-content-api/index.js +31 -0
- package/dist/storage-content-api/staticHandler.d.ts +10 -0
- package/dist/storage-content-api/staticHandler.js +63 -0
- package/dist/storage-content-api/types.d.ts +10 -0
- package/dist/storage-content-api/types.js +3 -0
- package/dist/storage-content-api/utilities/getSafeFilename.d.ts +12 -0
- package/dist/storage-content-api/utilities/getSafeFilename.js +61 -0
- package/dist/storage-content-api/utilities/index.d.ts +3 -0
- package/dist/storage-content-api/utilities/index.js +4 -0
- package/dist/storage-content-api/utilities/parseClientUploadContext.d.ts +19 -0
- package/dist/storage-content-api/utilities/parseClientUploadContext.js +30 -0
- package/dist/templates/.env.example +5 -0
- package/dist/templates/README.md +19 -0
- package/dist/types/config.d.ts +2 -1
- package/dist/types/config.js +0 -2
- package/dist/types.d.ts +10 -1
- package/dist/utils/adapters/nextjs.d.ts +9 -0
- package/dist/utils/adapters/nextjs.js +64 -0
- package/dist/utils/adapters/nitro.d.ts +9 -0
- package/dist/utils/adapters/nitro.js +169 -0
- package/dist/utils/adapters/vite.d.ts +10 -0
- package/dist/utils/adapters/vite.js +33 -0
- package/dist/utils/asset-collection.d.ts +27 -6
- package/dist/utils/asset-collection.js +59 -30
- package/dist/utils/build-detection.d.ts +5 -11
- package/dist/utils/build-detection.js +74 -11
- package/dist/utils/build-lambda-zip.d.ts +16 -0
- package/dist/utils/build-lambda-zip.js +78 -0
- package/dist/utils/cache-bootstrap.d.ts +8 -0
- package/dist/utils/cache-bootstrap.js +18 -0
- package/dist/utils/config.js +1 -1
- package/dist/utils/deploy-adapter.d.ts +40 -0
- package/dist/utils/deploy-adapter.js +58 -0
- package/dist/utils/download-template.d.ts +9 -1
- package/dist/utils/download-template.js +24 -18
- package/dist/utils/env-management.d.ts +24 -7
- package/dist/utils/env-management.js +119 -64
- package/dist/utils/format-env-suffix.d.ts +12 -0
- package/dist/utils/format-env-suffix.js +13 -0
- package/dist/utils/formatter.js +23 -11
- package/dist/utils/fs-utils.d.ts +6 -0
- package/dist/utils/fs-utils.js +27 -0
- package/dist/utils/handle-upgrade.d.ts +9 -0
- package/dist/utils/handle-upgrade.js +41 -0
- package/dist/utils/lambda-config.d.ts +3 -1
- package/dist/utils/lambda-config.js +75 -78
- package/dist/utils/messages.d.ts +1 -2
- package/dist/utils/messages.js +39 -11
- package/dist/utils/package-manager.d.ts +24 -0
- package/dist/utils/package-manager.js +53 -0
- package/dist/utils/parse-template-spec.d.ts +12 -0
- package/dist/utils/parse-template-spec.js +62 -0
- package/dist/utils/payload-config-ast.d.ts +27 -6
- package/dist/utils/payload-config-ast.js +106 -58
- package/dist/utils/payload-config-finder.d.ts +2 -2
- package/dist/utils/payload-config-finder.js +48 -9
- package/dist/utils/payload-config-modifier.d.ts +1 -1
- package/dist/utils/payload-config-modifier.js +114 -66
- package/dist/utils/payload-package-check.d.ts +33 -2
- package/dist/utils/payload-package-check.js +129 -28
- package/dist/utils/project.d.ts +7 -2
- package/dist/utils/project.js +60 -32
- package/dist/utils/resolve-environment.d.ts +14 -0
- package/dist/utils/resolve-environment.js +31 -0
- package/dist/utils/s3-upload.d.ts +7 -2
- package/dist/utils/s3-upload.js +39 -6
- package/dist/utils/token-display.d.ts +5 -1
- package/dist/utils/token-display.js +49 -22
- package/dist/utils/typescript-validator.js +4 -6
- package/dist/utils/version-check.d.ts +3 -0
- package/dist/utils/version-check.js +38 -0
- package/package.json +44 -15
- 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,42 @@
|
|
|
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
|
+
}
|
|
41
|
+
|
|
42
|
+
//# sourceMappingURL=transformPublishedLocale.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Payload } from 'payload';
|
|
2
|
+
export declare function validateRelationshipIds({ collectionSlug, data, payload, }: {
|
|
3
|
+
collectionSlug: string;
|
|
4
|
+
data: Record<string, unknown>;
|
|
5
|
+
payload: Payload;
|
|
6
|
+
}): void;
|
|
7
|
+
//# sourceMappingURL=validateRelationships.d.ts.map
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { traverseFields } from 'payload';
|
|
2
|
+
const UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
3
|
+
function collectRelationshipValues({ data, fields }) {
|
|
4
|
+
const relationships = [];
|
|
5
|
+
const callback = ({ field, ref })=>{
|
|
6
|
+
if (!('name' in field) || !field.name) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
if (field.type !== 'relationship' && field.type !== 'upload') {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
if (!ref || typeof ref !== 'object') {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const rawValue = ref[field.name];
|
|
16
|
+
if (rawValue == null || rawValue === '') {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
// For localized fields, the value is a locale map (e.g. { en: "uuid", fr: "uuid" }).
|
|
20
|
+
// Iterate locale values instead of treating the map as an ID.
|
|
21
|
+
if ('localized' in field && field.localized) {
|
|
22
|
+
if (typeof rawValue === 'object' && !Array.isArray(rawValue)) {
|
|
23
|
+
for (const localeValue of Object.values(rawValue)){
|
|
24
|
+
if (localeValue != null && localeValue !== '') {
|
|
25
|
+
parseRelationshipValues(localeValue, field.relationTo, relationships);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
parseRelationshipValues(rawValue, field.relationTo, relationships);
|
|
32
|
+
};
|
|
33
|
+
traverseFields({
|
|
34
|
+
callback,
|
|
35
|
+
fields,
|
|
36
|
+
fillEmpty: false,
|
|
37
|
+
ref: data
|
|
38
|
+
});
|
|
39
|
+
return relationships;
|
|
40
|
+
}
|
|
41
|
+
function parseRelationshipValues(value, relationTo, relationships) {
|
|
42
|
+
if (Array.isArray(relationTo)) {
|
|
43
|
+
// Polymorphic (single or hasMany): value is { relationTo, value } or array of them
|
|
44
|
+
const values = Array.isArray(value) ? value : [
|
|
45
|
+
value
|
|
46
|
+
];
|
|
47
|
+
for (const v of values){
|
|
48
|
+
if (v && typeof v === 'object' && 'relationTo' in v && 'value' in v) {
|
|
49
|
+
const obj = v;
|
|
50
|
+
if (obj.value != null && obj.value !== '') {
|
|
51
|
+
relationships.push({
|
|
52
|
+
collection: obj.relationTo,
|
|
53
|
+
value: obj.value
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
} else {
|
|
59
|
+
// Non-polymorphic (single or hasMany): value is a bare ID or array of IDs
|
|
60
|
+
const values = Array.isArray(value) ? value : [
|
|
61
|
+
value
|
|
62
|
+
];
|
|
63
|
+
for (const v of values){
|
|
64
|
+
if (v != null && v !== '') {
|
|
65
|
+
relationships.push({
|
|
66
|
+
collection: relationTo,
|
|
67
|
+
value: v
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
function isValidId(value, customIDType) {
|
|
74
|
+
if (customIDType === 'number') {
|
|
75
|
+
const num = typeof value === 'number' ? value : typeof value === 'string' ? Number(value) : NaN;
|
|
76
|
+
return Number.isFinite(num);
|
|
77
|
+
}
|
|
78
|
+
if (customIDType === 'text') {
|
|
79
|
+
return typeof value === 'string' && value.length > 0;
|
|
80
|
+
}
|
|
81
|
+
return typeof value === 'string' && UUID_REGEX.test(value);
|
|
82
|
+
}
|
|
83
|
+
export function validateRelationshipIds({ collectionSlug, data, payload }) {
|
|
84
|
+
const isGlobal = collectionSlug.startsWith('_global-');
|
|
85
|
+
const actualSlug = isGlobal ? collectionSlug.substring(8) : collectionSlug;
|
|
86
|
+
const config = isGlobal ? payload.config.globals?.find((g)=>g.slug === actualSlug) : payload.config.collections.find((c)=>c.slug === actualSlug);
|
|
87
|
+
if (!config?.fields) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
const relationships = collectRelationshipValues({
|
|
91
|
+
data,
|
|
92
|
+
fields: config.fields
|
|
93
|
+
});
|
|
94
|
+
for (const { collection, value } of relationships){
|
|
95
|
+
const customIDType = payload.collections?.[collection]?.customIDType;
|
|
96
|
+
if (!isValidId(value, customIDType)) {
|
|
97
|
+
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'}.`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
//# sourceMappingURL=validateRelationships.js.map
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { JoinQuery, Payload } from 'payload';
|
|
2
|
+
import type { components } from '../generated/content-api-types.js';
|
|
3
|
+
type ContentAPIJoin = components['schemas']['JoinClause'][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 join format:
|
|
36
|
+
* [{
|
|
37
|
+
* collectionId: 'posts', // collection to join FROM
|
|
38
|
+
* on: 'group.category', // field in joined collection pointing to this doc
|
|
39
|
+
* path: 'group.relatedPosts', // where to put results
|
|
40
|
+
* count: false,
|
|
41
|
+
* where: { ... }, // Content API where format
|
|
42
|
+
* sort: '-title',
|
|
43
|
+
* limit: 10,
|
|
44
|
+
* page: 2
|
|
45
|
+
* }]
|
|
46
|
+
*
|
|
47
|
+
* The mapping requires the collection config to resolve:
|
|
48
|
+
* - Which collection each join field refers to
|
|
49
|
+
* - What the 'on' field is for each join
|
|
50
|
+
*/
|
|
51
|
+
export declare function convertPayloadJoinsToContentAPI(payload: Payload, collectionSlug: string, joins: false | JoinQuery | undefined, locale?: string): ContentAPIJoin[] | undefined;
|
|
52
|
+
export {};
|
|
53
|
+
//# sourceMappingURL=joins.d.ts.map
|
|
@@ -0,0 +1,139 @@
|
|
|
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 join format:
|
|
35
|
+
* [{
|
|
36
|
+
* collectionId: 'posts', // collection to join FROM
|
|
37
|
+
* on: 'group.category', // field in joined collection pointing to this doc
|
|
38
|
+
* path: 'group.relatedPosts', // where to put results
|
|
39
|
+
* count: false,
|
|
40
|
+
* where: { ... }, // Content API where format
|
|
41
|
+
* sort: '-title',
|
|
42
|
+
* limit: 10,
|
|
43
|
+
* page: 2
|
|
44
|
+
* }]
|
|
45
|
+
*
|
|
46
|
+
* The mapping requires the collection config to resolve:
|
|
47
|
+
* - Which collection each join field refers to
|
|
48
|
+
* - What the 'on' field is for each join
|
|
49
|
+
*/ export function convertPayloadJoinsToContentAPI(payload, collectionSlug, joins, locale) {
|
|
50
|
+
const collectionConfig = payload.config.collections.find((c)=>c.slug === collectionSlug);
|
|
51
|
+
if (!collectionConfig) {
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
// joins === false means explicitly disable all joins
|
|
55
|
+
// joins === undefined means use defaults (no custom query params)
|
|
56
|
+
if (joins === false || !joins) {
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
const result = [];
|
|
60
|
+
// Iterate through all join paths in the query
|
|
61
|
+
for (const [joinPath, joinQueryValue] of Object.entries(joins)){
|
|
62
|
+
// joinQuery === false means skip this specific join
|
|
63
|
+
if (joinQueryValue === false) {
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
// Normalize undefined/empty to empty object
|
|
67
|
+
const joinQuery = joinQueryValue ?? {};
|
|
68
|
+
// Find the SanitizedJoin config for this joinPath
|
|
69
|
+
// SanitizedJoins is indexed by the collection being joined FROM
|
|
70
|
+
let foundJoin;
|
|
71
|
+
// Search through all collections in the joins config
|
|
72
|
+
for (const [collectionSlug, sanitizedJoins] of Object.entries(collectionConfig.joins)){
|
|
73
|
+
for (const sanitizedJoin of sanitizedJoins){
|
|
74
|
+
if (sanitizedJoin.joinPath === joinPath) {
|
|
75
|
+
const on = locale && sanitizedJoin.getForeignPath ? sanitizedJoin.getForeignPath({
|
|
76
|
+
locale
|
|
77
|
+
}) : sanitizedJoin.field.on;
|
|
78
|
+
foundJoin = {
|
|
79
|
+
collectionSlug,
|
|
80
|
+
defaultLimit: sanitizedJoin.field.defaultLimit,
|
|
81
|
+
defaultSort: sanitizedJoin.field.defaultSort,
|
|
82
|
+
on
|
|
83
|
+
};
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
if (foundJoin) {
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
// Also check polymorphic joins
|
|
92
|
+
if (!foundJoin) {
|
|
93
|
+
for (const sanitizedJoin of collectionConfig.polymorphicJoins){
|
|
94
|
+
if (sanitizedJoin.joinPath === joinPath) {
|
|
95
|
+
const collections = sanitizedJoin.field.collection;
|
|
96
|
+
const on = locale && sanitizedJoin.getForeignPath ? sanitizedJoin.getForeignPath({
|
|
97
|
+
locale
|
|
98
|
+
}) : sanitizedJoin.field.on;
|
|
99
|
+
foundJoin = {
|
|
100
|
+
collectionSlug: collections,
|
|
101
|
+
defaultSort: sanitizedJoin.field.defaultSort,
|
|
102
|
+
on
|
|
103
|
+
};
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
if (!foundJoin) {
|
|
109
|
+
payload.logger.warn(`Join path '${joinPath}' not found in collection config for '${collectionConfig.slug}'`);
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
// Fall back to the default limit if not specified in the query
|
|
113
|
+
const effectiveLimit = joinQuery.limit ?? foundJoin.defaultLimit;
|
|
114
|
+
// Add fallback sort for the joined collection
|
|
115
|
+
const sortWithFallback = addFallbackSort(joinQuery.sort, payload, foundJoin.collectionSlug, foundJoin.defaultSort);
|
|
116
|
+
const contentAPIJoin = {
|
|
117
|
+
collectionId: foundJoin.collectionSlug,
|
|
118
|
+
count: joinQuery.count ?? false,
|
|
119
|
+
on: foundJoin.on,
|
|
120
|
+
path: joinPath,
|
|
121
|
+
...effectiveLimit !== undefined && {
|
|
122
|
+
limit: effectiveLimit
|
|
123
|
+
},
|
|
124
|
+
...joinQuery.page && {
|
|
125
|
+
page: joinQuery.page
|
|
126
|
+
},
|
|
127
|
+
...sortWithFallback && {
|
|
128
|
+
sort: sortWithFallback
|
|
129
|
+
},
|
|
130
|
+
...joinQuery.where && {
|
|
131
|
+
where: convertPayloadWhereToContentAPI(joinQuery.where)
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
result.push(contentAPIJoin);
|
|
135
|
+
}
|
|
136
|
+
return result.length > 0 ? result : undefined;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
//# sourceMappingURL=joins.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
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;
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
}
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Payload } from 'payload';
|
|
2
|
+
/**
|
|
3
|
+
* Extracts all localized field paths from a collection's field configuration.
|
|
4
|
+
* Recursively traverses nested structures (groups, arrays, blocks, tabs) to find fields marked as localized.
|
|
5
|
+
*
|
|
6
|
+
* @param payload - The Payload instance containing collection configurations
|
|
7
|
+
* @param collectionSlug - The slug of the collection to extract localized paths from
|
|
8
|
+
* @returns Array of dot-notation paths to localized fields (e.g., ['title', 'metadata.description'])
|
|
9
|
+
*/
|
|
10
|
+
export declare function buildLocalizedPaths(payload: Payload, collectionSlug: string): string[];
|
|
11
|
+
//# sourceMappingURL=buildLocalizedPaths.d.ts.map
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extracts all localized field paths from a collection's field configuration.
|
|
3
|
+
* Recursively traverses nested structures (groups, arrays, blocks, tabs) to find fields marked as localized.
|
|
4
|
+
*
|
|
5
|
+
* @param payload - The Payload instance containing collection configurations
|
|
6
|
+
* @param collectionSlug - The slug of the collection to extract localized paths from
|
|
7
|
+
* @returns Array of dot-notation paths to localized fields (e.g., ['title', 'metadata.description'])
|
|
8
|
+
*/ export function buildLocalizedPaths(payload, collectionSlug) {
|
|
9
|
+
const collectionConfig = payload.config.collections.find((c)=>c.slug === collectionSlug);
|
|
10
|
+
if (!collectionConfig) {
|
|
11
|
+
return [];
|
|
12
|
+
}
|
|
13
|
+
const localizedPaths = [];
|
|
14
|
+
traverseFields(collectionConfig.fields, localizedPaths);
|
|
15
|
+
// Add _status to localized paths if localizeStatus is enabled for this collection
|
|
16
|
+
// _status is a base field added by Payload when versions.drafts is enabled,
|
|
17
|
+
// and it becomes localized when versions.drafts.localizeStatus is true
|
|
18
|
+
// localizeStatus requires both experimental flag AND collection-level config
|
|
19
|
+
const experimentalLocalizeStatus = 'experimental' in payload.config && payload.config.experimental && typeof payload.config.experimental === 'object' && 'localizeStatus' in payload.config.experimental && payload.config.experimental.localizeStatus === true;
|
|
20
|
+
const drafts = collectionConfig.versions && typeof collectionConfig.versions === 'object' ? collectionConfig.versions.drafts : false;
|
|
21
|
+
const collectionLocalizeStatus = drafts && typeof drafts === 'object' && 'localizeStatus' in drafts && drafts.localizeStatus === true;
|
|
22
|
+
const hasLocalizeStatus = payload.config.localization && experimentalLocalizeStatus && collectionLocalizeStatus;
|
|
23
|
+
if (hasLocalizeStatus && !localizedPaths.includes('_status')) {
|
|
24
|
+
localizedPaths.push('_status');
|
|
25
|
+
}
|
|
26
|
+
return localizedPaths;
|
|
27
|
+
}
|
|
28
|
+
/** Recursively traverses fields to find and collect localized paths */ function traverseFields(fields, localizedPaths, parentPath = '', parentIsLocalized = false) {
|
|
29
|
+
for (const field of fields){
|
|
30
|
+
// Unnamed layout fields (row, collapsible, unnamed group, unnamed tabs) don't store data
|
|
31
|
+
// at their own level, but their child fields may be localized. Recurse into them with
|
|
32
|
+
// the same parent path so localized fields bubble up correctly.
|
|
33
|
+
if (!('name' in field)) {
|
|
34
|
+
if ('fields' in field && Array.isArray(field.fields)) {
|
|
35
|
+
traverseFields(field.fields, localizedPaths, parentPath, parentIsLocalized);
|
|
36
|
+
}
|
|
37
|
+
if ('tabs' in field && Array.isArray(field.tabs)) {
|
|
38
|
+
for (const tab of field.tabs){
|
|
39
|
+
if (tab.fields) {
|
|
40
|
+
const tabPath = tab.name ? buildPath(parentPath, tab.name) : parentPath;
|
|
41
|
+
traverseFields(tab.fields, localizedPaths, tabPath, parentIsLocalized);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
const fieldPath = buildPath(parentPath, field.name);
|
|
48
|
+
const isLocalized = 'localized' in field && field.localized === true;
|
|
49
|
+
const includeNestedPaths = isLocalized || parentIsLocalized;
|
|
50
|
+
// Add field to results if localized or parent is localized
|
|
51
|
+
if (includeNestedPaths) {
|
|
52
|
+
localizedPaths.push(fieldPath);
|
|
53
|
+
}
|
|
54
|
+
// Handle blocks field - has a special 'blocks' array structure and each block has its own nested fields
|
|
55
|
+
if (field.type === 'blocks' && 'blocks' in field) {
|
|
56
|
+
for (const block of field.blocks){
|
|
57
|
+
if ('fields' in block) {
|
|
58
|
+
traverseFields(block.fields, localizedPaths, fieldPath, includeNestedPaths);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
// Handle field type that support nested fields
|
|
64
|
+
// Recursively handle nested structures (groups, arrays, tab, etc)
|
|
65
|
+
if ('fields' in field) {
|
|
66
|
+
traverseFields(field.fields, localizedPaths, fieldPath, includeNestedPaths);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/** Builds a dot-notation path from parent path and field name */ function buildPath(parentPath, fieldName) {
|
|
71
|
+
return parentPath ? `${parentPath}.${fieldName}` : fieldName;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
//# sourceMappingURL=buildLocalizedPaths.js.map
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { Payload, Where } from 'payload';
|
|
2
|
+
import type { components } from '../../generated/content-api-types.js';
|
|
3
|
+
import type { PathTypesRecord } from '../../temp-utilities/types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Metadata sent to Content API for query processing.
|
|
6
|
+
*
|
|
7
|
+
* TODO: This interface is defined here temporarily so Content API can test the integration.
|
|
8
|
+
* Once Content API implements support for pathTypes with relationship info, this type
|
|
9
|
+
* should be generated from openapi.json and ContentAPIMeta can be removed.
|
|
10
|
+
*/
|
|
11
|
+
export interface ContentAPIMeta {
|
|
12
|
+
localizedPaths?: string[];
|
|
13
|
+
pathTypes?: PathTypesRecord;
|
|
14
|
+
uniquePaths?: {
|
|
15
|
+
paths: string[];
|
|
16
|
+
}[];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The type that Content API currently expects (from generated types).
|
|
20
|
+
* This is more restrictive than ContentAPIMeta until Content API is updated.
|
|
21
|
+
*/
|
|
22
|
+
type ContentAPIMetaGenerated = components['schemas']['RequestMeta'];
|
|
23
|
+
export interface BuildMetaOptions {
|
|
24
|
+
collection: string;
|
|
25
|
+
/** Document data — when provided, unique field constraints are included in meta. */
|
|
26
|
+
data?: Record<string, unknown>;
|
|
27
|
+
locale: string | undefined;
|
|
28
|
+
where?: Where;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Builds the `meta` object for Content API requests.
|
|
32
|
+
* Combines pathTypes (for array field handling) and localizedPaths (for locale queries).
|
|
33
|
+
*
|
|
34
|
+
* @param payload - The Payload instance
|
|
35
|
+
* @param options - Options including collection slug, locale, and where clause
|
|
36
|
+
* @returns Object with meta property ready to spread into request body, or empty object if no meta needed
|
|
37
|
+
*/
|
|
38
|
+
export declare function buildMeta(payload: Payload, options: BuildMetaOptions): {
|
|
39
|
+
meta?: ContentAPIMetaGenerated;
|
|
40
|
+
};
|
|
41
|
+
export {};
|
|
42
|
+
//# sourceMappingURL=buildMeta.d.ts.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { buildLocalizedPaths } from './buildLocalizedPaths.js';
|
|
2
|
+
import { buildPathTypes } from './buildPathTypes.js';
|
|
3
|
+
import { buildUniquePaths } from './buildUniquePaths.js';
|
|
4
|
+
/**
|
|
5
|
+
* Builds the `meta` object for Content API requests.
|
|
6
|
+
* Combines pathTypes (for array field handling) and localizedPaths (for locale queries).
|
|
7
|
+
*
|
|
8
|
+
* @param payload - The Payload instance
|
|
9
|
+
* @param options - Options including collection slug, locale, and where clause
|
|
10
|
+
* @returns Object with meta property ready to spread into request body, or empty object if no meta needed
|
|
11
|
+
*/ export function buildMeta(payload, options) {
|
|
12
|
+
const { collection, data, locale, where } = options;
|
|
13
|
+
const meta = {};
|
|
14
|
+
// Add pathTypes if there are array fields in the where clause
|
|
15
|
+
const pathTypes = buildPathTypes(payload, collection, where);
|
|
16
|
+
if (Object.keys(pathTypes).length > 0) {
|
|
17
|
+
meta.pathTypes = pathTypes;
|
|
18
|
+
}
|
|
19
|
+
// Add localizedPaths if locale is specified (but not 'all')
|
|
20
|
+
if (locale && locale !== 'all') {
|
|
21
|
+
const localizedPaths = buildLocalizedPaths(payload, collection);
|
|
22
|
+
if (localizedPaths.length > 0) {
|
|
23
|
+
meta.localizedPaths = localizedPaths;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
// Add uniquePaths when data is provided (create/upsert operations)
|
|
27
|
+
if (data) {
|
|
28
|
+
const uniquePaths = buildUniquePaths(payload, collection, data);
|
|
29
|
+
if (uniquePaths.length > 0) {
|
|
30
|
+
meta.uniquePaths = uniquePaths;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
// Cast to generated type - Content API will need to be updated to handle
|
|
34
|
+
// the new pathTypes format with relationship info. Until then, it will
|
|
35
|
+
// ignore the extra fields but still receive the data for testing.
|
|
36
|
+
return Object.keys(meta).length > 0 ? {
|
|
37
|
+
meta: meta
|
|
38
|
+
} : {};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
//# sourceMappingURL=buildMeta.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Payload, Where } from 'payload';
|
|
2
|
+
import type { PathTypesRecord } from '../../temp-utilities/types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Builds pathTypes metadata for Content API request.
|
|
5
|
+
* Returns a record of paths with their types for proper query generation.
|
|
6
|
+
*
|
|
7
|
+
* Includes:
|
|
8
|
+
* - Array fields (type: "array")
|
|
9
|
+
* - Relationship fields (type: { type: "relationship", collection, hasMany })
|
|
10
|
+
* - Join fields (type: { type: "join", collection, hasMany, on })
|
|
11
|
+
*
|
|
12
|
+
* Localized array/blocks fields (stored as locale maps) are handled specially:
|
|
13
|
+
* - The localized field itself is NOT marked as 'array' (it's a locale map object)
|
|
14
|
+
* - The locale-specific path (e.g. "localizedBlocks.en") IS marked as 'array'
|
|
15
|
+
*/
|
|
16
|
+
export declare function buildPathTypes(payload: Payload, collectionSlug: string, where: undefined | Where): PathTypesRecord;
|
|
17
|
+
//# sourceMappingURL=buildPathTypes.d.ts.map
|