@payloadcms/figma 0.0.1-alpha.9 → 0.1.0-alpha.0
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 +7574 -0
- package/dist/db-content-api/generated/content-api-types.js +5 -0
- package/dist/db-content-api/index.d.ts +37 -0
- package/dist/db-content-api/index.js +938 -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/data/applyDefaults.d.ts +6 -0
- package/dist/db-content-api/utilities/data/applyDefaults.js +75 -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/index.d.ts +48 -0
- package/dist/db-content-api/utilities/data/index.js +299 -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/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 +100 -0
- package/dist/db-content-api/utilities/joins.d.ts +52 -0
- package/dist/db-content-api/utilities/joins.js +137 -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/buildLocalizedPaths.d.ts +10 -0
- package/dist/db-content-api/utilities/meta/buildLocalizedPaths.js +71 -0
- package/dist/db-content-api/utilities/meta/buildMeta.d.ts +41 -0
- package/dist/db-content-api/utilities/meta/buildMeta.js +39 -0
- package/dist/db-content-api/utilities/meta/buildPathTypes.d.ts +16 -0
- package/dist/db-content-api/utilities/meta/buildPathTypes.js +243 -0
- package/dist/db-content-api/utilities/meta/buildUniquePaths.d.ts +12 -0
- package/dist/db-content-api/utilities/meta/buildUniquePaths.js +60 -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 +55 -0
- package/dist/db-content-api/utilities/schema/buildDocumentSchema.js +182 -0
- package/dist/db-content-api/utilities/where.d.ts +19 -0
- package/dist/db-content-api/utilities/where.js +106 -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,41 @@
|
|
|
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 {};
|
|
@@ -0,0 +1,39 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
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;
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import { resolveBlocks } from '../resolveBlocks.js';
|
|
2
|
+
/**
|
|
3
|
+
* Extracts all field paths from a where clause recursively
|
|
4
|
+
*/ function extractPathsFromWhere(where, paths = new Set()) {
|
|
5
|
+
if (!where || typeof where !== 'object') {
|
|
6
|
+
return paths;
|
|
7
|
+
}
|
|
8
|
+
// Handle 'and' operator
|
|
9
|
+
if ('and' in where && Array.isArray(where.and)) {
|
|
10
|
+
for (const clause of where.and){
|
|
11
|
+
extractPathsFromWhere(clause, paths);
|
|
12
|
+
}
|
|
13
|
+
return paths;
|
|
14
|
+
}
|
|
15
|
+
// Handle 'or' operator
|
|
16
|
+
if ('or' in where && Array.isArray(where.or)) {
|
|
17
|
+
for (const clause of where.or){
|
|
18
|
+
extractPathsFromWhere(clause, paths);
|
|
19
|
+
}
|
|
20
|
+
return paths;
|
|
21
|
+
}
|
|
22
|
+
// Handle regular conditions - keys are field paths
|
|
23
|
+
for(const key in where){
|
|
24
|
+
if (key === 'and' || key === 'or') {
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
// Add the path
|
|
28
|
+
paths.add(key.replace(/__/g, '.'));
|
|
29
|
+
// Check if the value is a nested where clause (for relationships)
|
|
30
|
+
const value = where[key];
|
|
31
|
+
if (value && typeof value === 'object' && !('equals' in value) && !('in' in value)) {
|
|
32
|
+
// Might be a nested where, recurse
|
|
33
|
+
extractPathsFromWhere(value, paths);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return paths;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Determines the type of a field based on its configuration.
|
|
40
|
+
* Returns PathTypeValue for fields that need special handling in Content API queries.
|
|
41
|
+
*/ function getFieldType(field) {
|
|
42
|
+
// Array field
|
|
43
|
+
if (field.type === 'array') {
|
|
44
|
+
return 'array';
|
|
45
|
+
}
|
|
46
|
+
// Blocks field (array of objects)
|
|
47
|
+
if (field.type === 'blocks') {
|
|
48
|
+
return 'array';
|
|
49
|
+
}
|
|
50
|
+
// Relationship field - always include for JOIN support
|
|
51
|
+
if (field.type === 'relationship') {
|
|
52
|
+
const { hasMany = false, relationTo: collection } = field;
|
|
53
|
+
return {
|
|
54
|
+
type: 'relationship',
|
|
55
|
+
collection,
|
|
56
|
+
hasMany
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
// Upload field - treated like relationship
|
|
60
|
+
if (field.type === 'upload') {
|
|
61
|
+
const { hasMany = false, relationTo: collection } = field;
|
|
62
|
+
return {
|
|
63
|
+
type: 'relationship',
|
|
64
|
+
collection,
|
|
65
|
+
hasMany
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
// Join field - virtual reverse lookup
|
|
69
|
+
if (field.type === 'join') {
|
|
70
|
+
const { collection, on } = field;
|
|
71
|
+
return {
|
|
72
|
+
type: 'join',
|
|
73
|
+
collection,
|
|
74
|
+
hasMany: true,
|
|
75
|
+
on
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
// Text field with hasMany (array of strings)
|
|
79
|
+
if (field.type === 'text' && 'hasMany' in field && field.hasMany) {
|
|
80
|
+
return 'array';
|
|
81
|
+
}
|
|
82
|
+
// Number field with hasMany (array of numbers)
|
|
83
|
+
if (field.type === 'number' && 'hasMany' in field && field.hasMany) {
|
|
84
|
+
return 'array';
|
|
85
|
+
}
|
|
86
|
+
// Select field with hasMany (array)
|
|
87
|
+
if (field.type === 'select' && 'hasMany' in field && field.hasMany) {
|
|
88
|
+
return 'array';
|
|
89
|
+
}
|
|
90
|
+
// Objects (group, collapsible, row, tabs) don't need traversal
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Finds a field in the collection schema by its path.
|
|
95
|
+
* Supports nested paths like "access.read.users".
|
|
96
|
+
* For localized array/blocks fields, locale key segments (e.g. "en") are skipped transparently,
|
|
97
|
+
* so "localizedBlocks.en.richText" resolves to the richText field inside localizedBlocks.
|
|
98
|
+
*/ function findFieldByPath(payload, collectionSlug, path) {
|
|
99
|
+
const collectionConfig = payload.config.collections.find((c)=>c.slug === collectionSlug);
|
|
100
|
+
if (!collectionConfig) {
|
|
101
|
+
return undefined;
|
|
102
|
+
}
|
|
103
|
+
const localeCodes = payload.config.localization ? payload.config.localization.localeCodes : [];
|
|
104
|
+
const pathSegments = path.split('.');
|
|
105
|
+
// Walk through the path segments to find the field
|
|
106
|
+
let currentFields = collectionConfig.fields;
|
|
107
|
+
let currentField = undefined;
|
|
108
|
+
for(let i = 0; i < pathSegments.length; i++){
|
|
109
|
+
const segment = pathSegments[i];
|
|
110
|
+
// If this segment is a locale key for the previously found localized array/blocks field,
|
|
111
|
+
// skip it transparently (the locale key is the wrapping object key, not a real field).
|
|
112
|
+
if (localeCodes.includes(segment) && currentField && 'localized' in currentField && currentField.localized && (currentField.type === 'blocks' || currentField.type === 'array')) {
|
|
113
|
+
if (i === pathSegments.length - 1) {
|
|
114
|
+
// Last segment is a locale key → return the localized field (represents locale-specific array)
|
|
115
|
+
return currentField;
|
|
116
|
+
}
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
// First try to find a direct match
|
|
120
|
+
currentField = currentFields.find((f)=>'name' in f && f.name === segment);
|
|
121
|
+
// If not found, check if any unnamed container fields (collapsible, row) contain it
|
|
122
|
+
if (!currentField) {
|
|
123
|
+
for (const field of currentFields){
|
|
124
|
+
if (!('name' in field) || !field.name) {
|
|
125
|
+
// This is an unnamed field, check its contents
|
|
126
|
+
if ('fields' in field && field.type === 'collapsible' || 'fields' in field && field.type === 'row' || 'fields' in field && field.type === 'group') {
|
|
127
|
+
currentField = field.fields.find((f)=>'name' in f && f.name === segment);
|
|
128
|
+
if (currentField) {
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
} else if ('tabs' in field && field.type === 'tabs') {
|
|
132
|
+
// Check all tabs
|
|
133
|
+
for (const tab of field.tabs){
|
|
134
|
+
// Named tab: the tab name itself is a path segment (acts like a group)
|
|
135
|
+
if ('name' in tab && tab.name === segment) {
|
|
136
|
+
currentField = {
|
|
137
|
+
name: tab.name,
|
|
138
|
+
type: 'group',
|
|
139
|
+
fields: tab.fields
|
|
140
|
+
};
|
|
141
|
+
break;
|
|
142
|
+
}
|
|
143
|
+
// Unnamed tab: search its fields for the segment
|
|
144
|
+
const found = tab.fields.find((f)=>'name' in f && f.name === segment);
|
|
145
|
+
if (found) {
|
|
146
|
+
currentField = found;
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
if (currentField) {
|
|
151
|
+
break;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
if (!currentField) {
|
|
158
|
+
return undefined;
|
|
159
|
+
}
|
|
160
|
+
// If we're not at the end, get nested fields
|
|
161
|
+
if (i < pathSegments.length - 1) {
|
|
162
|
+
if (currentField.type === 'group' && 'fields' in currentField) {
|
|
163
|
+
currentFields = currentField.fields;
|
|
164
|
+
} else if (currentField.type === 'array' && 'fields' in currentField) {
|
|
165
|
+
currentFields = currentField.fields;
|
|
166
|
+
} else if (currentField.type === 'blocks' && 'blocks' in currentField) {
|
|
167
|
+
// Collect all fields from all block definitions to continue traversal
|
|
168
|
+
const allBlockFields = [];
|
|
169
|
+
for (const block of resolveBlocks(currentField.blocks, payload.config.blocks)){
|
|
170
|
+
allBlockFields.push(...block.fields);
|
|
171
|
+
}
|
|
172
|
+
currentFields = allBlockFields;
|
|
173
|
+
} else if ((currentField.type === 'relationship' || currentField.type === 'upload') && typeof currentField.relationTo === 'string') {
|
|
174
|
+
// Traverse into the related collection's fields
|
|
175
|
+
const { relationTo } = currentField;
|
|
176
|
+
const relatedConfig = payload.config.collections.find((c)=>c.slug === relationTo);
|
|
177
|
+
if (relatedConfig) {
|
|
178
|
+
currentFields = relatedConfig.fields;
|
|
179
|
+
} else {
|
|
180
|
+
return undefined;
|
|
181
|
+
}
|
|
182
|
+
} else {
|
|
183
|
+
// Field doesn't have nested fields, can't continue
|
|
184
|
+
return undefined;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
return currentField;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Builds pathTypes metadata for Content API request.
|
|
192
|
+
* Returns a record of paths with their types for proper query generation.
|
|
193
|
+
*
|
|
194
|
+
* Includes:
|
|
195
|
+
* - Array fields (type: "array")
|
|
196
|
+
* - Relationship fields (type: { type: "relationship", collection, hasMany })
|
|
197
|
+
* - Join fields (type: { type: "join", collection, hasMany, on })
|
|
198
|
+
*
|
|
199
|
+
* Localized array/blocks fields (stored as locale maps) are handled specially:
|
|
200
|
+
* - The localized field itself is NOT marked as 'array' (it's a locale map object)
|
|
201
|
+
* - The locale-specific path (e.g. "localizedBlocks.en") IS marked as 'array'
|
|
202
|
+
*/ export function buildPathTypes(payload, collectionSlug, where) {
|
|
203
|
+
if (!where) {
|
|
204
|
+
return {};
|
|
205
|
+
}
|
|
206
|
+
const localeCodes = payload.config.localization ? payload.config.localization.localeCodes : [];
|
|
207
|
+
const pathTypes = {};
|
|
208
|
+
const paths = extractPathsFromWhere(where);
|
|
209
|
+
for (const path of paths){
|
|
210
|
+
// For each path, we need to check all segments to see if any intermediate ones are arrays/relationships
|
|
211
|
+
const segments = path.split('.');
|
|
212
|
+
for(let i = 0; i < segments.length; i++){
|
|
213
|
+
const partialPath = segments.slice(0, i + 1).join('.');
|
|
214
|
+
// Skip if we already have this path
|
|
215
|
+
if (partialPath in pathTypes) {
|
|
216
|
+
continue;
|
|
217
|
+
}
|
|
218
|
+
// If the current segment is a locale code and the parent field is a localized array/blocks,
|
|
219
|
+
// mark this locale-specific path as 'array' (the per-locale content is the actual array).
|
|
220
|
+
if (i > 0 && localeCodes.includes(segments[i])) {
|
|
221
|
+
const parentPath = segments.slice(0, i).join('.');
|
|
222
|
+
const parentField = findFieldByPath(payload, collectionSlug, parentPath);
|
|
223
|
+
if (parentField && 'localized' in parentField && parentField.localized && (parentField.type === 'blocks' || parentField.type === 'array')) {
|
|
224
|
+
pathTypes[partialPath] = 'array';
|
|
225
|
+
continue;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
const field = findFieldByPath(payload, collectionSlug, partialPath);
|
|
229
|
+
if (field) {
|
|
230
|
+
// Localized array/blocks fields are stored as locale maps (not arrays).
|
|
231
|
+
// Skip them here — the locale-specific path (e.g. "localizedBlocks.en") is marked above.
|
|
232
|
+
if ('localized' in field && field.localized && (field.type === 'blocks' || field.type === 'array')) {
|
|
233
|
+
continue;
|
|
234
|
+
}
|
|
235
|
+
const fieldType = getFieldType(field);
|
|
236
|
+
if (fieldType !== null) {
|
|
237
|
+
pathTypes[partialPath] = fieldType;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
return pathTypes;
|
|
243
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Payload } from 'payload';
|
|
2
|
+
import type { components } from '../../generated/content-api-types.js';
|
|
3
|
+
type UniquePath = components['schemas']['UniquePath'];
|
|
4
|
+
/**
|
|
5
|
+
* Builds a UniquePath[] from the collection's field config by collecting
|
|
6
|
+
* all fields with `unique: true` that have a non-null value in the data.
|
|
7
|
+
*
|
|
8
|
+
* Fields with null/undefined values are excluded to match sparse unique index
|
|
9
|
+
* behavior (multiple documents can have null for a unique field).
|
|
10
|
+
*/
|
|
11
|
+
export declare function buildUniquePaths(payload: Payload, collectionSlug: string, data: Record<string, unknown>): UniquePath[];
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds a UniquePath[] from the collection's field config by collecting
|
|
3
|
+
* all fields with `unique: true` that have a non-null value in the data.
|
|
4
|
+
*
|
|
5
|
+
* Fields with null/undefined values are excluded to match sparse unique index
|
|
6
|
+
* behavior (multiple documents can have null for a unique field).
|
|
7
|
+
*/ export function buildUniquePaths(payload, collectionSlug, data) {
|
|
8
|
+
const isGlobal = collectionSlug.startsWith('_global-');
|
|
9
|
+
const actualSlug = isGlobal ? collectionSlug.substring(8) : collectionSlug;
|
|
10
|
+
const config = isGlobal ? payload.config.globals?.find((g)=>g.slug === actualSlug) : payload.config.collections.find((c)=>c.slug === actualSlug);
|
|
11
|
+
if (!config?.fields) {
|
|
12
|
+
return [];
|
|
13
|
+
}
|
|
14
|
+
const unique = [];
|
|
15
|
+
collectUniqueFields(config.fields, '', data, unique);
|
|
16
|
+
return unique;
|
|
17
|
+
}
|
|
18
|
+
function getValueAtPath(data, path) {
|
|
19
|
+
const segments = path.split('.');
|
|
20
|
+
let current = data;
|
|
21
|
+
for (const segment of segments){
|
|
22
|
+
if (current == null || typeof current !== 'object') {
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
current = current[segment];
|
|
26
|
+
}
|
|
27
|
+
return current;
|
|
28
|
+
}
|
|
29
|
+
function collectUniqueFields(fields, prefix, data, result) {
|
|
30
|
+
for (const field of fields){
|
|
31
|
+
if (field.type === 'row' || field.type === 'collapsible') {
|
|
32
|
+
collectUniqueFields(field.fields, prefix, data, result);
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
if (field.type === 'tabs') {
|
|
36
|
+
for (const tab of field.tabs){
|
|
37
|
+
const tabPrefix = 'name' in tab && tab.name ? `${prefix}${tab.name}.` : prefix;
|
|
38
|
+
collectUniqueFields(tab.fields, tabPrefix, data, result);
|
|
39
|
+
}
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
if (!('name' in field) || !field.name) {
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
const path = prefix + field.name;
|
|
46
|
+
if ('unique' in field && field.unique) {
|
|
47
|
+
const value = getValueAtPath(data, path);
|
|
48
|
+
if (value != null) {
|
|
49
|
+
result.push({
|
|
50
|
+
paths: [
|
|
51
|
+
path
|
|
52
|
+
]
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
if (field.type === 'group' && 'fields' in field) {
|
|
57
|
+
collectUniqueFields(field.fields, `${path}.`, data, result);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -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;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Collects paths of localized array/blocks fields in a collection.
|
|
3
|
+
* These fields are stored as locale maps (e.g. {"en": [...], "es": [...]}) rather than
|
|
4
|
+
* direct arrays, so queries must include the locale key in the path.
|
|
5
|
+
*/ function collectLocalizedArrayPaths(fields, prefix, paths) {
|
|
6
|
+
for (const field of fields){
|
|
7
|
+
if (!('name' in field) || !field.name) {
|
|
8
|
+
// Unnamed container (row, collapsible) — recurse into its fields
|
|
9
|
+
if ('fields' in field && Array.isArray(field.fields)) {
|
|
10
|
+
collectLocalizedArrayPaths(field.fields, prefix, paths);
|
|
11
|
+
}
|
|
12
|
+
if ('tabs' in field && Array.isArray(field.tabs)) {
|
|
13
|
+
for (const tab of field.tabs){
|
|
14
|
+
const tabPath = tab.name ? prefix ? `${prefix}.${tab.name}` : tab.name : prefix;
|
|
15
|
+
if (tab.fields) {
|
|
16
|
+
collectLocalizedArrayPaths(tab.fields, tabPath, paths);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
const fieldPath = prefix ? `${prefix}.${field.name}` : field.name;
|
|
23
|
+
if ('localized' in field && field.localized && (field.type === 'array' || field.type === 'blocks')) {
|
|
24
|
+
paths.push(fieldPath);
|
|
25
|
+
// Don't recurse further — child paths are accessed via locale key, handled separately
|
|
26
|
+
} else if (field.type === 'group' && 'fields' in field) {
|
|
27
|
+
collectLocalizedArrayPaths(field.fields, fieldPath, paths);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Returns the paths of all localized array/blocks fields for the given collection.
|
|
33
|
+
*/ function getLocalizedArrayPaths(payload, collectionSlug) {
|
|
34
|
+
const config = payload.config.collections.find((c)=>c.slug === collectionSlug);
|
|
35
|
+
if (!config) {
|
|
36
|
+
return [];
|
|
37
|
+
}
|
|
38
|
+
const paths = [];
|
|
39
|
+
collectLocalizedArrayPaths(config.fields, '', paths);
|
|
40
|
+
return paths;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Transforms a single path by inserting the locale after a localized array/blocks prefix
|
|
44
|
+
* if the path goes through one without an explicit locale key.
|
|
45
|
+
*
|
|
46
|
+
* Example:
|
|
47
|
+
* path "localizedBlocks.richText.children.text", localizedArrayPaths ["localizedBlocks"],
|
|
48
|
+
* locale "en", localeCodes ["en", "es"]
|
|
49
|
+
* → "localizedBlocks.en.richText.children.text"
|
|
50
|
+
*
|
|
51
|
+
* path "localizedBlocks.en.richText.children.text" (already has locale)
|
|
52
|
+
* → unchanged
|
|
53
|
+
*/ function insertLocaleInPath(path, localizedArrayPaths, locale, localeCodes) {
|
|
54
|
+
for (const lpath of localizedArrayPaths){
|
|
55
|
+
if (path.startsWith(lpath + '.')) {
|
|
56
|
+
const rest = path.slice(lpath.length + 1);
|
|
57
|
+
const firstSegment = rest.split('.')[0];
|
|
58
|
+
if (!localeCodes.includes(firstSegment)) {
|
|
59
|
+
return `${lpath}.${locale}.${rest}`;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return path;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Recursively transforms all condition paths in a Where clause by inserting the locale key
|
|
67
|
+
* after any localized array/blocks field prefix that is missing one.
|
|
68
|
+
*
|
|
69
|
+
* This is needed because localized array/blocks fields are stored as locale maps
|
|
70
|
+
* (e.g. data.localizedBlocks.en = [...]) rather than flat arrays. Without the locale
|
|
71
|
+
* key, the path would point to the locale map object, causing jsonb_array_elements to fail.
|
|
72
|
+
*/ function transformWhere(where, localizedArrayPaths, locale, localeCodes) {
|
|
73
|
+
const result = {};
|
|
74
|
+
for (const [key, value] of Object.entries(where)){
|
|
75
|
+
if (key === 'and' || key === 'or') {
|
|
76
|
+
result[key] = value.map((clause)=>transformWhere(clause, localizedArrayPaths, locale, localeCodes));
|
|
77
|
+
} else {
|
|
78
|
+
const normalizedKey = insertLocaleInPath(key, localizedArrayPaths, locale, localeCodes);
|
|
79
|
+
result[normalizedKey] = value;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return result;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Normalizes a Where clause by inserting locale keys into paths that traverse
|
|
86
|
+
* localized array/blocks fields without an explicit locale.
|
|
87
|
+
*
|
|
88
|
+
* Only runs when a locale is provided and the collection has localized array/blocks fields.
|
|
89
|
+
* Returns the original where clause if no transformation is needed.
|
|
90
|
+
*/ export function normalizeLocaleInWhere(where, payload, collectionSlug, locale) {
|
|
91
|
+
if (!where || !locale || !payload.config.localization) {
|
|
92
|
+
return where;
|
|
93
|
+
}
|
|
94
|
+
const localeCodes = payload.config.localization.localeCodes;
|
|
95
|
+
const localizedArrayPaths = getLocalizedArrayPaths(payload, collectionSlug);
|
|
96
|
+
if (localizedArrayPaths.length === 0) {
|
|
97
|
+
return where;
|
|
98
|
+
}
|
|
99
|
+
return transformWhere(where, localizedArrayPaths, locale, localeCodes);
|
|
100
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Block, FlattenedBlock } from 'payload';
|
|
2
|
+
/**
|
|
3
|
+
* Dereferences a blocks field's entries into full block definitions.
|
|
4
|
+
*
|
|
5
|
+
* v4 stores block-reference-by-slug: a blocks field's `blocks` array may contain
|
|
6
|
+
* string slugs pointing at config-level shared blocks (`config.blocks`) instead of
|
|
7
|
+
* inline block definitions. Callers that need each block's `fields` must resolve
|
|
8
|
+
* those string references first. Unresolvable references are dropped.
|
|
9
|
+
*/
|
|
10
|
+
export declare function resolveBlocks(blocks: (Block | string)[], configBlocks?: FlattenedBlock[]): Block[];
|
|
11
|
+
/**
|
|
12
|
+
* Resolves the flattened block definition matching a given `blockType`, following
|
|
13
|
+
* config-level string references. Returns `undefined` when no block matches.
|
|
14
|
+
*/
|
|
15
|
+
export declare function resolveFlattenedBlock({ blocks, blockType, configBlocks, }: {
|
|
16
|
+
blocks: (FlattenedBlock | string)[];
|
|
17
|
+
blockType: unknown;
|
|
18
|
+
configBlocks?: FlattenedBlock[];
|
|
19
|
+
}): FlattenedBlock | undefined;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dereferences a blocks field's entries into full block definitions.
|
|
3
|
+
*
|
|
4
|
+
* v4 stores block-reference-by-slug: a blocks field's `blocks` array may contain
|
|
5
|
+
* string slugs pointing at config-level shared blocks (`config.blocks`) instead of
|
|
6
|
+
* inline block definitions. Callers that need each block's `fields` must resolve
|
|
7
|
+
* those string references first. Unresolvable references are dropped.
|
|
8
|
+
*/ export function resolveBlocks(blocks, configBlocks) {
|
|
9
|
+
const resolved = [];
|
|
10
|
+
for (const block of blocks){
|
|
11
|
+
if (typeof block !== 'string') {
|
|
12
|
+
resolved.push(block);
|
|
13
|
+
continue;
|
|
14
|
+
}
|
|
15
|
+
const match = configBlocks?.find((each)=>each.slug === block);
|
|
16
|
+
if (match) {
|
|
17
|
+
resolved.push(match);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return resolved;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Resolves the flattened block definition matching a given `blockType`, following
|
|
24
|
+
* config-level string references. Returns `undefined` when no block matches.
|
|
25
|
+
*/ export function resolveFlattenedBlock({ blocks, blockType, configBlocks }) {
|
|
26
|
+
const match = blocks.find((each)=>(typeof each === 'string' ? each : each.slug) === blockType);
|
|
27
|
+
if (typeof match !== 'string') {
|
|
28
|
+
return match;
|
|
29
|
+
}
|
|
30
|
+
return configBlocks?.find((each)=>each.slug === match);
|
|
31
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { Config } from 'payload';
|
|
2
|
+
/**
|
|
3
|
+
* Wire form of the v1 `DocumentSchema` sent on every request so the server can
|
|
4
|
+
* classify each queried path against the index tables. Paths are
|
|
5
|
+
* period-delimited (e.g. `author.name`).
|
|
6
|
+
*/
|
|
7
|
+
export interface DocumentSchemaWire {
|
|
8
|
+
collections: Record<string, WireCollectionSchema>;
|
|
9
|
+
version: 1;
|
|
10
|
+
}
|
|
11
|
+
interface WireCollectionSchema {
|
|
12
|
+
hints: WireHint[];
|
|
13
|
+
name: string;
|
|
14
|
+
paths: Record<string, WireFieldSchema>;
|
|
15
|
+
}
|
|
16
|
+
type WireHint = {
|
|
17
|
+
paths: string[];
|
|
18
|
+
type: 'unique';
|
|
19
|
+
};
|
|
20
|
+
type WireFieldSchema = {
|
|
21
|
+
collection: string | string[];
|
|
22
|
+
on: string;
|
|
23
|
+
type: 'join';
|
|
24
|
+
} | {
|
|
25
|
+
collection: string | string[];
|
|
26
|
+
hasMany: boolean;
|
|
27
|
+
localized: boolean;
|
|
28
|
+
type: 'relationship' | 'upload';
|
|
29
|
+
unique: boolean;
|
|
30
|
+
} | {
|
|
31
|
+
format: 'lexical';
|
|
32
|
+
localized: boolean;
|
|
33
|
+
type: 'richText';
|
|
34
|
+
} | {
|
|
35
|
+
hasMany: boolean;
|
|
36
|
+
localized: boolean;
|
|
37
|
+
type: 'group';
|
|
38
|
+
} | {
|
|
39
|
+
hasMany: boolean;
|
|
40
|
+
localized: boolean;
|
|
41
|
+
type: 'number' | 'select' | 'text';
|
|
42
|
+
unique: boolean;
|
|
43
|
+
} | {
|
|
44
|
+
localized: boolean;
|
|
45
|
+
type: 'array' | 'blocks';
|
|
46
|
+
} | {
|
|
47
|
+
localized: boolean;
|
|
48
|
+
type: 'checkbox' | 'date' | 'json' | 'radio';
|
|
49
|
+
} | {
|
|
50
|
+
localized: boolean;
|
|
51
|
+
type: 'code' | 'email' | 'point' | 'textarea';
|
|
52
|
+
unique: boolean;
|
|
53
|
+
};
|
|
54
|
+
export declare function buildDocumentSchema(config: Config): DocumentSchemaWire;
|
|
55
|
+
export {};
|