@payloadcms/figma 0.0.1-alpha.9 → 0.1.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/control-plane.d.ts +56 -7
- package/dist/api/control-plane.js +188 -74
- package/dist/api/error-response.d.ts +36 -0
- package/dist/api/error-response.js +66 -0
- package/dist/api/figma-api.d.ts +24 -3
- package/dist/api/figma-api.js +110 -34
- package/dist/auth/browser.d.ts +0 -1
- package/dist/auth/browser.js +0 -2
- package/dist/auth/callback-server.d.ts +19 -8
- package/dist/auth/callback-server.js +72 -32
- package/dist/auth/credentials.d.ts +20 -0
- package/dist/auth/credentials.js +19 -0
- package/dist/auth/crypto-utils.d.ts +28 -1
- package/dist/auth/crypto-utils.js +132 -23
- package/dist/auth/jwt-validator.d.ts +23 -6
- package/dist/auth/jwt-validator.js +35 -9
- package/dist/auth/oauth-flow.d.ts +19 -4
- package/dist/auth/oauth-flow.js +151 -34
- package/dist/auth/paste-code.d.ts +33 -0
- package/dist/auth/paste-code.js +87 -0
- package/dist/auth/pkce.d.ts +0 -1
- package/dist/auth/pkce.js +0 -2
- package/dist/auth/project-token.d.ts +32 -17
- package/dist/auth/project-token.js +176 -68
- package/dist/auth/refresh.d.ts +2 -2
- package/dist/auth/refresh.js +25 -14
- package/dist/auth/token-store-migration.d.ts +57 -0
- package/dist/auth/token-store-migration.js +154 -0
- package/dist/auth/token-store.d.ts +63 -98
- package/dist/auth/token-store.js +405 -124
- package/dist/auth/types.d.ts +40 -6
- package/dist/auth/types.js +1 -3
- package/dist/cli.d.ts +0 -1
- package/dist/cli.js +102 -8
- package/dist/commands/bootstrap.d.ts +17 -0
- package/dist/commands/bootstrap.js +88 -0
- package/dist/commands/build-lambda-zip.d.ts +4 -0
- package/dist/commands/build-lambda-zip.js +17 -0
- package/dist/commands/debug.d.ts +7 -0
- package/dist/commands/debug.js +178 -0
- package/dist/commands/deploy.d.ts +11 -1
- package/dist/commands/deploy.js +193 -153
- package/dist/commands/dump-tokens.d.ts +11 -0
- package/dist/commands/dump-tokens.js +67 -0
- package/dist/commands/env.d.ts +12 -0
- package/dist/commands/env.js +86 -0
- package/dist/commands/init.d.ts +9 -6
- package/dist/commands/init.js +232 -152
- package/dist/commands/list-tokens.d.ts +3 -4
- package/dist/commands/list-tokens.js +24 -11
- package/dist/commands/login.d.ts +8 -2
- package/dist/commands/login.js +34 -18
- package/dist/commands/logout.d.ts +5 -5
- package/dist/commands/logout.js +77 -17
- package/dist/commands/upgrade.d.ts +4 -0
- package/dist/commands/upgrade.js +329 -0
- package/dist/commands/upload-schema.d.ts +8 -0
- package/dist/commands/upload-schema.js +91 -0
- package/dist/config/oauth.d.ts +17 -12
- package/dist/config/oauth.js +38 -39
- package/dist/constants.d.ts +63 -19
- package/dist/constants.js +158 -20
- package/dist/db-content-api/generated/content-api-types.d.ts +8215 -0
- package/dist/db-content-api/generated/content-api-types.js +5 -0
- package/dist/db-content-api/index.d.ts +40 -0
- package/dist/db-content-api/index.js +883 -0
- package/dist/db-content-api/temp-utilities/slug.d.ts +1 -0
- package/dist/db-content-api/temp-utilities/slug.js +1 -0
- package/dist/db-content-api/temp-utilities/sorting.d.ts +2 -0
- package/dist/db-content-api/temp-utilities/sorting.js +37 -0
- package/dist/db-content-api/temp-utilities/types.d.ts +21 -0
- package/dist/db-content-api/temp-utilities/types.js +13 -0
- package/dist/db-content-api/temp-utilities/unwrapDocument.d.ts +38 -0
- package/dist/db-content-api/temp-utilities/unwrapDocument.js +62 -0
- package/dist/db-content-api/utilities/auth.d.ts +29 -0
- package/dist/db-content-api/utilities/auth.js +82 -0
- package/dist/db-content-api/utilities/clientVersionHeaders.d.ts +7 -0
- package/dist/db-content-api/utilities/clientVersionHeaders.js +15 -0
- package/dist/db-content-api/utilities/data/applyDefaults.d.ts +6 -0
- package/dist/db-content-api/utilities/data/applyDefaults.js +75 -0
- package/dist/db-content-api/utilities/data/atomicOperations.d.ts +16 -0
- package/dist/db-content-api/utilities/data/atomicOperations.js +48 -0
- package/dist/db-content-api/utilities/data/castFieldValue.d.ts +10 -0
- package/dist/db-content-api/utilities/data/castFieldValue.js +66 -0
- package/dist/db-content-api/utilities/data/convertRelationshipIds.d.ts +25 -0
- package/dist/db-content-api/utilities/data/convertRelationshipIds.js +109 -0
- package/dist/db-content-api/utilities/data/index.d.ts +48 -0
- package/dist/db-content-api/utilities/data/index.js +315 -0
- package/dist/db-content-api/utilities/data/isLocaleMap.d.ts +10 -0
- package/dist/db-content-api/utilities/data/isLocaleMap.js +13 -0
- package/dist/db-content-api/utilities/data/pointShape.d.ts +3 -0
- package/dist/db-content-api/utilities/data/pointShape.js +43 -0
- package/dist/db-content-api/utilities/data/removeVirtualFields.d.ts +11 -0
- package/dist/db-content-api/utilities/data/removeVirtualFields.js +52 -0
- package/dist/db-content-api/utilities/data/resolveFieldLocalization.d.ts +18 -0
- package/dist/db-content-api/utilities/data/resolveFieldLocalization.js +21 -0
- package/dist/db-content-api/utilities/data/richTextShape.d.ts +3 -0
- package/dist/db-content-api/utilities/data/richTextShape.js +56 -0
- package/dist/db-content-api/utilities/data/stripFields.d.ts +47 -0
- package/dist/db-content-api/utilities/data/stripFields.js +170 -0
- package/dist/db-content-api/utilities/data/transformPublishedLocale.d.ts +22 -0
- package/dist/db-content-api/utilities/data/transformPublishedLocale.js +40 -0
- package/dist/db-content-api/utilities/data/validateRelationships.d.ts +6 -0
- package/dist/db-content-api/utilities/data/validateRelationships.js +107 -0
- package/dist/db-content-api/utilities/joins.d.ts +50 -0
- package/dist/db-content-api/utilities/joins.js +124 -0
- package/dist/db-content-api/utilities/locale/index.d.ts +9 -0
- package/dist/db-content-api/utilities/locale/index.js +19 -0
- package/dist/db-content-api/utilities/meta/normalizeLocaleInWhere.d.ts +9 -0
- package/dist/db-content-api/utilities/meta/normalizeLocaleInWhere.js +100 -0
- package/dist/db-content-api/utilities/resolveBlocks.d.ts +19 -0
- package/dist/db-content-api/utilities/resolveBlocks.js +31 -0
- package/dist/db-content-api/utilities/schema/buildDocumentSchema.d.ts +72 -0
- package/dist/db-content-api/utilities/schema/buildDocumentSchema.js +264 -0
- package/dist/db-content-api/utilities/where.d.ts +9 -0
- package/dist/db-content-api/utilities/where.js +95 -0
- package/dist/deploy/schedule-extract-plugin.d.ts +10 -0
- package/dist/deploy/schedule-extract-plugin.js +32 -0
- package/dist/endpoints/health.d.ts +2 -0
- package/dist/endpoints/health.js +9 -0
- package/dist/endpoints/schema.d.ts +2 -0
- package/dist/endpoints/schema.js +27 -0
- package/dist/exports/client.d.ts +2 -1
- package/dist/exports/client.js +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -3
- package/dist/lib/download-skill.d.ts +12 -0
- package/dist/lib/download-skill.js +77 -0
- package/dist/oauth/components/FigmaAvatar/index.d.ts +3 -0
- package/dist/oauth/components/FigmaAvatar/index.js +25 -0
- package/dist/oauth/components/FigmaAvatar/index.scss +12 -0
- package/dist/oauth/components/FigmaAvatarCell/index.d.ts +4 -0
- package/dist/oauth/components/FigmaAvatarCell/index.js +23 -0
- package/dist/oauth/components/FigmaAvatarCell/index.scss +5 -0
- package/dist/oauth/components/FigmaAvatarPlaceholder/index.d.ts +8 -0
- package/dist/oauth/components/FigmaAvatarPlaceholder/index.js +35 -0
- package/dist/oauth/components/FigmaAvatarPlaceholder/index.scss +28 -0
- package/dist/oauth/components/LoginButton/iframeAutoLogin.d.ts +81 -0
- package/dist/oauth/components/LoginButton/iframeAutoLogin.js +168 -0
- package/dist/oauth/components/LoginButton/index.d.ts +0 -1
- package/dist/oauth/components/LoginButton/index.js +156 -18
- package/dist/oauth/components/LoginButton/index.scss +75 -3
- package/dist/oauth/components/LogoutButton/index.d.ts +0 -1
- package/dist/oauth/components/LogoutButton/index.js +20 -9
- package/dist/oauth/defaults.d.ts +3 -2
- package/dist/oauth/defaults.js +79 -12
- package/dist/oauth/endpoints/getLoginEndpoint.d.ts +0 -1
- package/dist/oauth/endpoints/getLoginEndpoint.js +87 -84
- package/dist/oauth/endpoints/getLogoutEndpoint.d.ts +0 -1
- package/dist/oauth/endpoints/getLogoutEndpoint.js +7 -6
- package/dist/oauth/endpoints/getMetaEndpoint.d.ts +0 -1
- package/dist/oauth/endpoints/getMetaEndpoint.js +18 -5
- package/dist/oauth/endpoints/getRedirectToLoginEndpoint.d.ts +0 -1
- package/dist/oauth/endpoints/getRedirectToLoginEndpoint.js +11 -4
- package/dist/oauth/exports/client.d.ts +0 -1
- package/dist/oauth/exports/client.js +0 -2
- package/dist/oauth/hooks/afterLogout.d.ts +0 -1
- package/dist/oauth/hooks/afterLogout.js +0 -2
- package/dist/oauth/hooks/me.d.ts +0 -1
- package/dist/oauth/hooks/me.js +0 -2
- package/dist/oauth/hooks/refresh.d.ts +0 -1
- package/dist/oauth/hooks/refresh.js +2 -3
- package/dist/oauth/index.d.ts +0 -1
- package/dist/oauth/index.js +27 -7
- package/dist/oauth/strategy/index.d.ts +0 -3
- package/dist/oauth/strategy/index.js +55 -34
- package/dist/oauth/types.d.ts +23 -7
- package/dist/oauth/types.js +0 -2
- package/dist/oauth/utilities/buildUnauthorizedRedirect.d.ts +14 -0
- package/dist/oauth/utilities/buildUnauthorizedRedirect.js +28 -0
- package/dist/oauth/utilities/clearCookie.d.ts +0 -1
- package/dist/oauth/utilities/clearCookie.js +5 -3
- package/dist/oauth/utilities/createCookieOptions.d.ts +0 -1
- package/dist/oauth/utilities/createCookieOptions.js +9 -4
- package/dist/oauth/utilities/createDebugLogger.d.ts +0 -1
- package/dist/oauth/utilities/createDebugLogger.js +0 -2
- package/dist/oauth/utilities/establishSession.d.ts +22 -0
- package/dist/oauth/utilities/establishSession.js +80 -0
- package/dist/oauth/utilities/exchangeCodeForAccessToken.d.ts +23 -0
- package/dist/oauth/utilities/exchangeCodeForAccessToken.js +26 -0
- package/dist/oauth/utilities/extractOrigin.d.ts +0 -1
- package/dist/oauth/utilities/extractOrigin.js +0 -2
- package/dist/oauth/utilities/figmaHostnames.d.ts +2 -0
- package/dist/oauth/utilities/figmaHostnames.js +24 -0
- package/dist/oauth/utilities/getAdminCollectionSlug.d.ts +0 -1
- package/dist/oauth/utilities/getAdminCollectionSlug.js +0 -2
- package/dist/oauth/utilities/getAuthorizeURL.d.ts +65 -2
- package/dist/oauth/utilities/getAuthorizeURL.js +57 -4
- package/dist/oauth/utilities/getCookieExpiration.d.ts +0 -1
- package/dist/oauth/utilities/getCookieExpiration.js +0 -2
- package/dist/oauth/utilities/getSecondsFromTokenExp.d.ts +0 -1
- package/dist/oauth/utilities/getSecondsFromTokenExp.js +0 -2
- package/dist/oauth/utilities/getTokenExp.d.ts +0 -1
- package/dist/oauth/utilities/getTokenExp.js +0 -2
- package/dist/oauth/utilities/getUsernameField.d.ts +0 -1
- package/dist/oauth/utilities/getUsernameField.js +0 -2
- package/dist/oauth/utilities/hasUserTokenPropsChanged.d.ts +0 -1
- package/dist/oauth/utilities/hasUserTokenPropsChanged.js +0 -2
- package/dist/oauth/utilities/isAbsoluteURL.d.ts +1 -0
- package/dist/oauth/utilities/isAbsoluteURL.js +1 -0
- package/dist/oauth/utilities/isDuplicateKeyError.d.ts +6 -0
- package/dist/oauth/utilities/isDuplicateKeyError.js +12 -0
- package/dist/oauth/utilities/mergeHeaders.d.ts +0 -1
- package/dist/oauth/utilities/mergeHeaders.js +0 -2
- package/dist/oauth/utilities/refreshTokens.d.ts +0 -1
- package/dist/oauth/utilities/refreshTokens.js +21 -13
- package/dist/oauth/utilities/withPartitionedCookie.d.ts +19 -0
- package/dist/oauth/utilities/withPartitionedCookie.js +26 -0
- package/dist/oauth/utils/getSearchParam.d.ts +17 -0
- package/dist/oauth/utils/getSearchParam.js +22 -0
- package/dist/plugin/adapter.d.ts +0 -1
- package/dist/plugin/adapter.js +0 -2
- package/dist/plugin/auth-preflight.d.ts +7 -0
- package/dist/plugin/auth-preflight.js +18 -0
- package/dist/plugin/bootstrap-preflight.d.ts +22 -0
- package/dist/plugin/bootstrap-preflight.js +43 -0
- package/dist/plugin/build-config.d.ts +27 -15
- package/dist/plugin/build-config.js +380 -16
- package/dist/plugin/dev-cookie-names.d.ts +13 -0
- package/dist/plugin/dev-cookie-names.js +17 -0
- package/dist/scss.d.js +2 -0
- package/dist/storage-content-api/api-types.d.ts +183 -0
- package/dist/storage-content-api/api-types.js +4 -0
- package/dist/storage-content-api/client-uploads/generate.d.ts +14 -0
- package/dist/storage-content-api/client-uploads/generate.js +69 -0
- package/dist/storage-content-api/client.d.ts +5 -0
- package/dist/storage-content-api/client.js +37 -0
- package/dist/storage-content-api/generateURL.d.ts +6 -0
- package/dist/storage-content-api/generateURL.js +6 -0
- package/dist/storage-content-api/handleDelete.d.ts +7 -0
- package/dist/storage-content-api/handleDelete.js +15 -0
- package/dist/storage-content-api/handleUpload.d.ts +10 -0
- package/dist/storage-content-api/handleUpload.js +162 -0
- package/dist/storage-content-api/index.d.ts +4 -0
- package/dist/storage-content-api/index.js +37 -0
- package/dist/storage-content-api/staticHandler.d.ts +9 -0
- package/dist/storage-content-api/staticHandler.js +61 -0
- package/dist/storage-content-api/types.d.ts +9 -0
- package/dist/storage-content-api/types.js +1 -0
- package/dist/storage-content-api/utilities/getSafeFilename.d.ts +11 -0
- package/dist/storage-content-api/utilities/getSafeFilename.js +59 -0
- package/dist/storage-content-api/utilities/index.d.ts +2 -0
- package/dist/storage-content-api/utilities/index.js +2 -0
- package/dist/storage-content-api/utilities/parseUploadReference.d.ts +17 -0
- package/dist/storage-content-api/utilities/parseUploadReference.js +27 -0
- package/dist/templates/.env.example +5 -0
- package/dist/templates/README.md +19 -0
- package/dist/types/config.d.ts +2 -2
- package/dist/types/config.js +0 -4
- package/dist/types.d.ts +10 -2
- package/dist/types.js +0 -2
- package/dist/utils/adapters/nextjs.d.ts +8 -0
- package/dist/utils/adapters/nextjs.js +61 -0
- package/dist/utils/adapters/nitro.d.ts +8 -0
- package/dist/utils/adapters/nitro.js +172 -0
- package/dist/utils/adapters/vite.d.ts +9 -0
- package/dist/utils/adapters/vite.js +31 -0
- package/dist/utils/asset-collection.d.ts +27 -7
- package/dist/utils/asset-collection.js +59 -32
- package/dist/utils/build-detection.d.ts +5 -12
- package/dist/utils/build-detection.js +74 -13
- package/dist/utils/build-lambda-zip.d.ts +25 -0
- package/dist/utils/build-lambda-zip.js +90 -0
- package/dist/utils/cache-bootstrap.d.ts +7 -0
- package/dist/utils/cache-bootstrap.js +16 -0
- package/dist/utils/config.d.ts +0 -1
- package/dist/utils/config.js +1 -3
- package/dist/utils/deploy-adapter.d.ts +45 -0
- package/dist/utils/deploy-adapter.js +56 -0
- package/dist/utils/download-template.d.ts +9 -2
- package/dist/utils/download-template.js +24 -20
- package/dist/utils/env-management.d.ts +24 -8
- package/dist/utils/env-management.js +119 -66
- package/dist/utils/format-env-suffix.d.ts +11 -0
- package/dist/utils/format-env-suffix.js +11 -0
- package/dist/utils/format.d.ts +0 -1
- package/dist/utils/format.js +0 -2
- package/dist/utils/formatter.d.ts +0 -1
- package/dist/utils/formatter.js +23 -13
- package/dist/utils/fs-utils.d.ts +12 -0
- package/dist/utils/fs-utils.js +55 -0
- package/dist/utils/git.d.ts +0 -1
- package/dist/utils/git.js +0 -2
- package/dist/utils/handle-upgrade.d.ts +8 -0
- package/dist/utils/handle-upgrade.js +39 -0
- package/dist/utils/is-debug.d.ts +0 -1
- package/dist/utils/is-debug.js +0 -2
- package/dist/utils/lambda-config.d.ts +3 -2
- package/dist/utils/lambda-config.js +75 -80
- package/dist/utils/load-payload-config.d.ts +9 -0
- package/dist/utils/load-payload-config.js +27 -0
- package/dist/utils/log.d.ts +0 -1
- package/dist/utils/log.js +0 -2
- package/dist/utils/messages.d.ts +1 -3
- package/dist/utils/messages.js +47 -13
- package/dist/utils/package-manager.d.ts +24 -1
- package/dist/utils/package-manager.js +53 -2
- package/dist/utils/parse-template-spec.d.ts +11 -0
- package/dist/utils/parse-template-spec.js +60 -0
- package/dist/utils/payload-config-ast.d.ts +27 -7
- package/dist/utils/payload-config-ast.js +106 -60
- package/dist/utils/payload-config-finder.d.ts +2 -3
- package/dist/utils/payload-config-finder.js +48 -11
- package/dist/utils/payload-config-modifier.d.ts +1 -2
- package/dist/utils/payload-config-modifier.js +114 -68
- package/dist/utils/payload-package-check.d.ts +28 -3
- package/dist/utils/payload-package-check.js +90 -31
- package/dist/utils/project.d.ts +8 -4
- package/dist/utils/project.js +63 -37
- package/dist/utils/resolve-environment.d.ts +13 -0
- package/dist/utils/resolve-environment.js +29 -0
- package/dist/utils/s3-upload.d.ts +7 -3
- package/dist/utils/s3-upload.js +44 -9
- package/dist/utils/token-display.d.ts +5 -2
- package/dist/utils/token-display.js +49 -24
- package/dist/utils/typescript-validator.d.ts +0 -1
- package/dist/utils/typescript-validator.js +4 -8
- package/dist/utils/version-check.d.ts +2 -0
- package/dist/utils/version-check.js +43 -0
- package/package.json +47 -16
- package/dist/api/control-plane.d.ts.map +0 -1
- package/dist/api/control-plane.js.map +0 -1
- package/dist/api/figma-api.d.ts.map +0 -1
- package/dist/api/figma-api.js.map +0 -1
- package/dist/auth/browser.d.ts.map +0 -1
- package/dist/auth/browser.js.map +0 -1
- package/dist/auth/callback-server.d.ts.map +0 -1
- package/dist/auth/callback-server.js.map +0 -1
- package/dist/auth/crypto-utils.d.ts.map +0 -1
- package/dist/auth/crypto-utils.js.map +0 -1
- package/dist/auth/jwt-validator.d.ts.map +0 -1
- package/dist/auth/jwt-validator.js.map +0 -1
- package/dist/auth/oauth-flow.d.ts.map +0 -1
- package/dist/auth/oauth-flow.js.map +0 -1
- package/dist/auth/pkce.d.ts.map +0 -1
- package/dist/auth/pkce.js.map +0 -1
- package/dist/auth/project-token.d.ts.map +0 -1
- package/dist/auth/project-token.js.map +0 -1
- package/dist/auth/refresh.d.ts.map +0 -1
- package/dist/auth/refresh.js.map +0 -1
- package/dist/auth/token-store.d.ts.map +0 -1
- package/dist/auth/token-store.js.map +0 -1
- package/dist/auth/types.d.ts.map +0 -1
- package/dist/auth/types.js.map +0 -1
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/commands/deploy.d.ts.map +0 -1
- package/dist/commands/deploy.js.map +0 -1
- package/dist/commands/init.d.ts.map +0 -1
- package/dist/commands/init.js.map +0 -1
- package/dist/commands/list-tokens.d.ts.map +0 -1
- package/dist/commands/list-tokens.js.map +0 -1
- package/dist/commands/login.d.ts.map +0 -1
- package/dist/commands/login.js.map +0 -1
- package/dist/commands/logout.d.ts.map +0 -1
- package/dist/commands/logout.js.map +0 -1
- package/dist/config/oauth.d.ts.map +0 -1
- package/dist/config/oauth.js.map +0 -1
- package/dist/constants.d.ts.map +0 -1
- package/dist/constants.js.map +0 -1
- package/dist/exports/client.d.ts.map +0 -1
- package/dist/exports/client.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/oauth/components/LoginButton/index.d.ts.map +0 -1
- package/dist/oauth/components/LoginButton/index.js.map +0 -1
- package/dist/oauth/components/LogoutButton/index.d.ts.map +0 -1
- package/dist/oauth/components/LogoutButton/index.js.map +0 -1
- package/dist/oauth/defaults.d.ts.map +0 -1
- package/dist/oauth/defaults.js.map +0 -1
- package/dist/oauth/endpoints/getLoginEndpoint.d.ts.map +0 -1
- package/dist/oauth/endpoints/getLoginEndpoint.js.map +0 -1
- package/dist/oauth/endpoints/getLogoutEndpoint.d.ts.map +0 -1
- package/dist/oauth/endpoints/getLogoutEndpoint.js.map +0 -1
- package/dist/oauth/endpoints/getMetaEndpoint.d.ts.map +0 -1
- package/dist/oauth/endpoints/getMetaEndpoint.js.map +0 -1
- package/dist/oauth/endpoints/getRedirectToLoginEndpoint.d.ts.map +0 -1
- package/dist/oauth/endpoints/getRedirectToLoginEndpoint.js.map +0 -1
- package/dist/oauth/exports/client.d.ts.map +0 -1
- package/dist/oauth/exports/client.js.map +0 -1
- package/dist/oauth/hooks/afterLogout.d.ts.map +0 -1
- package/dist/oauth/hooks/afterLogout.js.map +0 -1
- package/dist/oauth/hooks/me.d.ts.map +0 -1
- package/dist/oauth/hooks/me.js.map +0 -1
- package/dist/oauth/hooks/refresh.d.ts.map +0 -1
- package/dist/oauth/hooks/refresh.js.map +0 -1
- package/dist/oauth/index.d.ts.map +0 -1
- package/dist/oauth/index.js.map +0 -1
- package/dist/oauth/strategy/index.d.ts.map +0 -1
- package/dist/oauth/strategy/index.js.map +0 -1
- package/dist/oauth/types.d.ts.map +0 -1
- package/dist/oauth/types.js.map +0 -1
- package/dist/oauth/utilities/clearCookie.d.ts.map +0 -1
- package/dist/oauth/utilities/clearCookie.js.map +0 -1
- package/dist/oauth/utilities/createCookieOptions.d.ts.map +0 -1
- package/dist/oauth/utilities/createCookieOptions.js.map +0 -1
- package/dist/oauth/utilities/createDebugLogger.d.ts.map +0 -1
- package/dist/oauth/utilities/createDebugLogger.js.map +0 -1
- package/dist/oauth/utilities/extractOrigin.d.ts.map +0 -1
- package/dist/oauth/utilities/extractOrigin.js.map +0 -1
- package/dist/oauth/utilities/getAdminCollectionSlug.d.ts.map +0 -1
- package/dist/oauth/utilities/getAdminCollectionSlug.js.map +0 -1
- package/dist/oauth/utilities/getAdminPath.d.ts +0 -8
- package/dist/oauth/utilities/getAdminPath.d.ts.map +0 -1
- package/dist/oauth/utilities/getAdminPath.js +0 -9
- package/dist/oauth/utilities/getAdminPath.js.map +0 -1
- package/dist/oauth/utilities/getAuthorizeURL.d.ts.map +0 -1
- package/dist/oauth/utilities/getAuthorizeURL.js.map +0 -1
- package/dist/oauth/utilities/getCookieExpiration.d.ts.map +0 -1
- package/dist/oauth/utilities/getCookieExpiration.js.map +0 -1
- package/dist/oauth/utilities/getSecondsFromTokenExp.d.ts.map +0 -1
- package/dist/oauth/utilities/getSecondsFromTokenExp.js.map +0 -1
- package/dist/oauth/utilities/getTokenExp.d.ts.map +0 -1
- package/dist/oauth/utilities/getTokenExp.js.map +0 -1
- package/dist/oauth/utilities/getUsernameField.d.ts.map +0 -1
- package/dist/oauth/utilities/getUsernameField.js.map +0 -1
- package/dist/oauth/utilities/hasUserTokenPropsChanged.d.ts.map +0 -1
- package/dist/oauth/utilities/hasUserTokenPropsChanged.js.map +0 -1
- package/dist/oauth/utilities/mergeHeaders.d.ts.map +0 -1
- package/dist/oauth/utilities/mergeHeaders.js.map +0 -1
- package/dist/oauth/utilities/refreshTokens.d.ts.map +0 -1
- package/dist/oauth/utilities/refreshTokens.js.map +0 -1
- package/dist/plugin/adapter.d.ts.map +0 -1
- package/dist/plugin/adapter.js.map +0 -1
- package/dist/plugin/build-config.d.ts.map +0 -1
- package/dist/plugin/build-config.js.map +0 -1
- package/dist/types/config.d.ts.map +0 -1
- package/dist/types/config.js.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/utils/asset-collection.d.ts.map +0 -1
- package/dist/utils/asset-collection.js.map +0 -1
- package/dist/utils/build-detection.d.ts.map +0 -1
- package/dist/utils/build-detection.js.map +0 -1
- package/dist/utils/config.d.ts.map +0 -1
- package/dist/utils/config.js.map +0 -1
- package/dist/utils/download-template.d.ts.map +0 -1
- package/dist/utils/download-template.js.map +0 -1
- package/dist/utils/env-management.d.ts.map +0 -1
- package/dist/utils/env-management.js.map +0 -1
- package/dist/utils/format.d.ts.map +0 -1
- package/dist/utils/format.js.map +0 -1
- package/dist/utils/formatter.d.ts.map +0 -1
- package/dist/utils/formatter.js.map +0 -1
- package/dist/utils/git.d.ts.map +0 -1
- package/dist/utils/git.js.map +0 -1
- package/dist/utils/is-debug.d.ts.map +0 -1
- package/dist/utils/is-debug.js.map +0 -1
- package/dist/utils/lambda-config.d.ts.map +0 -1
- package/dist/utils/lambda-config.js.map +0 -1
- package/dist/utils/log.d.ts.map +0 -1
- package/dist/utils/log.js.map +0 -1
- package/dist/utils/messages.d.ts.map +0 -1
- package/dist/utils/messages.js.map +0 -1
- package/dist/utils/package-manager.d.ts.map +0 -1
- package/dist/utils/package-manager.js.map +0 -1
- package/dist/utils/payload-config-ast.d.ts.map +0 -1
- package/dist/utils/payload-config-ast.js.map +0 -1
- package/dist/utils/payload-config-finder.d.ts.map +0 -1
- package/dist/utils/payload-config-finder.js.map +0 -1
- package/dist/utils/payload-config-modifier.d.ts.map +0 -1
- package/dist/utils/payload-config-modifier.js.map +0 -1
- package/dist/utils/payload-package-check.d.ts.map +0 -1
- package/dist/utils/payload-package-check.js.map +0 -1
- package/dist/utils/project.d.ts.map +0 -1
- package/dist/utils/project.js.map +0 -1
- package/dist/utils/s3-upload.d.ts.map +0 -1
- package/dist/utils/s3-upload.js.map +0 -1
- package/dist/utils/token-display.d.ts.map +0 -1
- package/dist/utils/token-display.js.map +0 -1
- package/dist/utils/typescript-validator.d.ts.map +0 -1
- package/dist/utils/typescript-validator.js.map +0 -1
|
@@ -0,0 +1,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,72 @@
|
|
|
1
|
+
import type { Config, SanitizedConfig } 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
|
+
* `localized` on a path is the flag *declared* by the Payload field, not a
|
|
8
|
+
* statement about where locale keys appear in the data. Payload nests locale keys
|
|
9
|
+
* at the outermost localized field on a path and stores everything beneath it
|
|
10
|
+
* plainly; the Content API resolves that absorption itself while walking a path,
|
|
11
|
+
* because a block entity is shared across the schema and can be referenced from
|
|
12
|
+
* both a localized and a non-localized `blocks` field. Read paths that need the
|
|
13
|
+
* resolved flag on this side use `isLocaleAbsorbed`.
|
|
14
|
+
*/
|
|
15
|
+
export interface DocumentSchemaWire {
|
|
16
|
+
blocks: Record<string, WireBlockSchema>;
|
|
17
|
+
collections: Record<string, WireCollectionSchema>;
|
|
18
|
+
version: 1;
|
|
19
|
+
}
|
|
20
|
+
interface WireCollectionSchema {
|
|
21
|
+
hints: WireHint[];
|
|
22
|
+
name: string;
|
|
23
|
+
paths: Record<string, WireFieldSchema>;
|
|
24
|
+
}
|
|
25
|
+
interface WireBlockSchema {
|
|
26
|
+
name: string;
|
|
27
|
+
paths: Record<string, WireFieldSchema>;
|
|
28
|
+
}
|
|
29
|
+
type WireHint = {
|
|
30
|
+
paths: string[];
|
|
31
|
+
type: 'unique';
|
|
32
|
+
};
|
|
33
|
+
type WireFieldSchema = {
|
|
34
|
+
blocks: Record<string, string>;
|
|
35
|
+
localized: boolean;
|
|
36
|
+
type: 'blocks';
|
|
37
|
+
} | {
|
|
38
|
+
collection: string | string[];
|
|
39
|
+
on: string;
|
|
40
|
+
type: 'join';
|
|
41
|
+
} | {
|
|
42
|
+
collection: string | string[];
|
|
43
|
+
hasMany: boolean;
|
|
44
|
+
localized: boolean;
|
|
45
|
+
type: 'relationship' | 'upload';
|
|
46
|
+
unique: boolean;
|
|
47
|
+
} | {
|
|
48
|
+
format: 'lexical';
|
|
49
|
+
localized: boolean;
|
|
50
|
+
type: 'richText';
|
|
51
|
+
} | {
|
|
52
|
+
hasMany: boolean;
|
|
53
|
+
localized: boolean;
|
|
54
|
+
type: 'group';
|
|
55
|
+
} | {
|
|
56
|
+
hasMany: boolean;
|
|
57
|
+
localized: boolean;
|
|
58
|
+
type: 'number' | 'select' | 'text';
|
|
59
|
+
unique: boolean;
|
|
60
|
+
} | {
|
|
61
|
+
localized: boolean;
|
|
62
|
+
type: 'array';
|
|
63
|
+
} | {
|
|
64
|
+
localized: boolean;
|
|
65
|
+
type: 'checkbox' | 'date' | 'json' | 'radio';
|
|
66
|
+
} | {
|
|
67
|
+
localized: boolean;
|
|
68
|
+
type: 'code' | 'email' | 'point' | 'slug' | 'textarea';
|
|
69
|
+
unique: boolean;
|
|
70
|
+
};
|
|
71
|
+
export declare function buildDocumentSchema(config: Config | SanitizedConfig): DocumentSchemaWire;
|
|
72
|
+
export {};
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
// Built-in document fields the Content API manages itself (stored as columns and
|
|
2
|
+
// injected into every schema). They must never be sent as declared fields, so any
|
|
3
|
+
// top-level field with one of these names is dropped. This applies only to
|
|
4
|
+
// documents: blocks have no built-in fields, so a block field named `id` or
|
|
5
|
+
// `createdAt` is a real declared field and must be kept.
|
|
6
|
+
const BUILT_IN_FIELD_NAMES = new Set([
|
|
7
|
+
'createdAt',
|
|
8
|
+
'id',
|
|
9
|
+
'updatedAt'
|
|
10
|
+
]);
|
|
11
|
+
const BLOCK_TYPE_FIELD_NAME = 'blockType';
|
|
12
|
+
// The implicit block-type discriminator carried on every block row. It is not a
|
|
13
|
+
// declared block field, so it is injected into each block entity's paths.
|
|
14
|
+
const BLOCK_TYPE_FIELD = {
|
|
15
|
+
type: 'text',
|
|
16
|
+
hasMany: false,
|
|
17
|
+
localized: false,
|
|
18
|
+
unique: false
|
|
19
|
+
};
|
|
20
|
+
export function buildDocumentSchema(config) {
|
|
21
|
+
const globalBlocksBySlug = new Map();
|
|
22
|
+
for (const block of config.blocks ?? []){
|
|
23
|
+
globalBlocksBySlug.set(block.slug, block);
|
|
24
|
+
}
|
|
25
|
+
const blockRegistry = {
|
|
26
|
+
blocksById: {},
|
|
27
|
+
globalBlocksBySlug,
|
|
28
|
+
idByBlock: new Map()
|
|
29
|
+
};
|
|
30
|
+
const collections = {};
|
|
31
|
+
for (const collection of config.collections ?? []){
|
|
32
|
+
collections[collection.slug] = buildCollectionSchema(collection.slug, collection.fields, blockRegistry);
|
|
33
|
+
}
|
|
34
|
+
for (const global of config.globals ?? []){
|
|
35
|
+
const slug = `_global-${global.slug}`;
|
|
36
|
+
collections[slug] = buildCollectionSchema(slug, global.fields, blockRegistry);
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
blocks: blockRegistry.blocksById,
|
|
40
|
+
collections,
|
|
41
|
+
version: 1
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function buildCollectionSchema(name, fields, blockRegistry) {
|
|
45
|
+
const paths = {};
|
|
46
|
+
collectPaths(fields, paths, {
|
|
47
|
+
blockRegistry,
|
|
48
|
+
inBlock: false,
|
|
49
|
+
prefix: ''
|
|
50
|
+
});
|
|
51
|
+
// `_payloadAutosave` marks a version as an autosave draft. The Content API wraps
|
|
52
|
+
// version schemas under the `version` envelope, so this becomes `version._payloadAutosave`
|
|
53
|
+
// there. This adds the field to both the document and document version schemas as there
|
|
54
|
+
// is no way to add it to just one. However, fields present in the collection schema but
|
|
55
|
+
// not in the request payload are ignored, so this is safe to add to both.
|
|
56
|
+
if (!('_payloadAutosave' in paths)) {
|
|
57
|
+
paths._payloadAutosave = {
|
|
58
|
+
type: 'checkbox',
|
|
59
|
+
localized: false
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
name,
|
|
64
|
+
hints: [],
|
|
65
|
+
paths
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
function collectPaths(fields, paths, context) {
|
|
69
|
+
const { prefix } = context;
|
|
70
|
+
for (const field of fields){
|
|
71
|
+
if (field.type === 'row' || field.type === 'collapsible' || field.type === 'group' && (!('name' in field) || !field.name)) {
|
|
72
|
+
collectPaths(field.fields, paths, context);
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
if (field.type === 'tabs') {
|
|
76
|
+
for (const tab of field.tabs){
|
|
77
|
+
if ('name' in tab && tab.name) {
|
|
78
|
+
paths[`${prefix}${tab.name}`] = {
|
|
79
|
+
type: 'group',
|
|
80
|
+
hasMany: false,
|
|
81
|
+
localized: 'localized' in tab && tab.localized === true
|
|
82
|
+
};
|
|
83
|
+
collectPaths(tab.fields, paths, {
|
|
84
|
+
...context,
|
|
85
|
+
prefix: `${prefix}${tab.name}.`
|
|
86
|
+
});
|
|
87
|
+
} else {
|
|
88
|
+
collectPaths(tab.fields, paths, context);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
if (field.type === 'ui' || !('name' in field) || !field.name) {
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
collectNamedField(field, paths, context);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function collectNamedField(field, paths, context) {
|
|
100
|
+
const { inBlock, prefix } = context;
|
|
101
|
+
if (!('name' in field) || !field.name) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
// Built-in fields are supplied by the Content API, never declared here. Blocks
|
|
105
|
+
// have no built-ins, so their fields are never pruned.
|
|
106
|
+
if (prefix === '' && !inBlock && BUILT_IN_FIELD_NAMES.has(field.name)) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
const path = `${prefix}${field.name}`;
|
|
110
|
+
const localized = 'localized' in field && field.localized === true;
|
|
111
|
+
const hasMany = 'hasMany' in field ? Boolean(field.hasMany) : false;
|
|
112
|
+
const unique = 'unique' in field ? Boolean(field.unique) : false;
|
|
113
|
+
switch(field.type){
|
|
114
|
+
case 'array':
|
|
115
|
+
paths[path] = {
|
|
116
|
+
type: 'array',
|
|
117
|
+
localized
|
|
118
|
+
};
|
|
119
|
+
collectPaths(field.fields, paths, {
|
|
120
|
+
...context,
|
|
121
|
+
prefix: `${path}.`
|
|
122
|
+
});
|
|
123
|
+
return;
|
|
124
|
+
case 'blocks':
|
|
125
|
+
{
|
|
126
|
+
const blocks = collectBlocks(field, context);
|
|
127
|
+
paths[path] = {
|
|
128
|
+
type: 'blocks',
|
|
129
|
+
blocks,
|
|
130
|
+
localized
|
|
131
|
+
};
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
case 'checkbox':
|
|
135
|
+
case 'date':
|
|
136
|
+
case 'json':
|
|
137
|
+
case 'radio':
|
|
138
|
+
paths[path] = {
|
|
139
|
+
type: field.type,
|
|
140
|
+
localized
|
|
141
|
+
};
|
|
142
|
+
return;
|
|
143
|
+
case 'code':
|
|
144
|
+
case 'email':
|
|
145
|
+
case 'point':
|
|
146
|
+
case 'slug':
|
|
147
|
+
case 'textarea':
|
|
148
|
+
paths[path] = {
|
|
149
|
+
type: field.type,
|
|
150
|
+
localized,
|
|
151
|
+
unique
|
|
152
|
+
};
|
|
153
|
+
return;
|
|
154
|
+
case 'group':
|
|
155
|
+
paths[path] = {
|
|
156
|
+
type: 'group',
|
|
157
|
+
hasMany,
|
|
158
|
+
localized
|
|
159
|
+
};
|
|
160
|
+
collectPaths(field.fields, paths, {
|
|
161
|
+
...context,
|
|
162
|
+
prefix: `${path}.`
|
|
163
|
+
});
|
|
164
|
+
return;
|
|
165
|
+
case 'join':
|
|
166
|
+
paths[path] = {
|
|
167
|
+
type: 'join',
|
|
168
|
+
collection: field.collection,
|
|
169
|
+
on: field.on
|
|
170
|
+
};
|
|
171
|
+
return;
|
|
172
|
+
case 'number':
|
|
173
|
+
case 'select':
|
|
174
|
+
case 'text':
|
|
175
|
+
paths[path] = {
|
|
176
|
+
type: field.type,
|
|
177
|
+
hasMany,
|
|
178
|
+
localized,
|
|
179
|
+
unique
|
|
180
|
+
};
|
|
181
|
+
return;
|
|
182
|
+
case 'relationship':
|
|
183
|
+
case 'upload':
|
|
184
|
+
paths[path] = {
|
|
185
|
+
type: field.type,
|
|
186
|
+
collection: field.relationTo,
|
|
187
|
+
hasMany,
|
|
188
|
+
localized,
|
|
189
|
+
unique
|
|
190
|
+
};
|
|
191
|
+
return;
|
|
192
|
+
case 'richText':
|
|
193
|
+
paths[path] = {
|
|
194
|
+
type: 'richText',
|
|
195
|
+
format: 'lexical',
|
|
196
|
+
localized
|
|
197
|
+
};
|
|
198
|
+
return;
|
|
199
|
+
default:
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
function collectBlocks(field, context) {
|
|
204
|
+
const blocks = {};
|
|
205
|
+
// Each block type is stored as its own entity; the field records only the
|
|
206
|
+
// block-type -> entity-id mapping. This lets same-named fields across block
|
|
207
|
+
// types keep independent schemas instead of collapsing to one shape.
|
|
208
|
+
for (const ref of field.blocks){
|
|
209
|
+
const blockId = resolveBlockId(ref, context);
|
|
210
|
+
if (blockId != null) {
|
|
211
|
+
const slug = typeof ref === 'string' ? ref : ref.slug;
|
|
212
|
+
blocks[slug] = blockId;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
return blocks;
|
|
216
|
+
}
|
|
217
|
+
// Resolves the block a field references (by inline config or slug), applying
|
|
218
|
+
// Payload's block-type resolution: a globally-registered block wins over a
|
|
219
|
+
// field-local inline block of the same slug. Returns the assigned entity id, or
|
|
220
|
+
// `null` when the slug cannot be resolved.
|
|
221
|
+
function resolveBlockId(ref, context) {
|
|
222
|
+
const { blockRegistry } = context;
|
|
223
|
+
const block = resolveBlockReferenceToBlock(ref, context);
|
|
224
|
+
if (block == null) {
|
|
225
|
+
return null;
|
|
226
|
+
}
|
|
227
|
+
const existingBlockId = blockRegistry.idByBlock.get(block);
|
|
228
|
+
if (existingBlockId != null) {
|
|
229
|
+
return existingBlockId;
|
|
230
|
+
}
|
|
231
|
+
const newBlockId = `block_${blockRegistry.idByBlock.size}`;
|
|
232
|
+
blockRegistry.idByBlock.set(block, newBlockId);
|
|
233
|
+
const newBlockPaths = {
|
|
234
|
+
[BLOCK_TYPE_FIELD_NAME]: {
|
|
235
|
+
...BLOCK_TYPE_FIELD
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
// A block entity is its own path namespace, so prefixing resets here. A block
|
|
239
|
+
// entity is shared by every `blocks` field that references it — including a
|
|
240
|
+
// localized one — so it records each field's declared `localized` flag and
|
|
241
|
+
// lets the Content API resolve locale absorption per reference while walking
|
|
242
|
+
// the path. Everything collected below lives in a block, not a document.
|
|
243
|
+
collectPaths(block.fields, newBlockPaths, {
|
|
244
|
+
blockRegistry,
|
|
245
|
+
inBlock: true,
|
|
246
|
+
prefix: ''
|
|
247
|
+
});
|
|
248
|
+
blockRegistry.blocksById[newBlockId] = {
|
|
249
|
+
name: block.slug,
|
|
250
|
+
paths: newBlockPaths
|
|
251
|
+
};
|
|
252
|
+
return newBlockId;
|
|
253
|
+
}
|
|
254
|
+
function resolveBlockReferenceToBlock(ref, context) {
|
|
255
|
+
// Local blocks are stored inline in the field definition.
|
|
256
|
+
const slug = typeof ref === 'string' ? ref : ref.slug;
|
|
257
|
+
const localBlock = typeof ref === 'string' ? undefined : ref;
|
|
258
|
+
// Global blocks are stored as slugs that reference blocks
|
|
259
|
+
// defined at the config level.
|
|
260
|
+
const globalBlock = context.blockRegistry.globalBlocksBySlug.get(slug);
|
|
261
|
+
// Global blocks must take precedence. This mirrors existing Payload
|
|
262
|
+
// behavior.
|
|
263
|
+
return globalBlock ?? localBlock;
|
|
264
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Where } from 'payload';
|
|
2
|
+
import type { components } from '../generated/content-api-types.js';
|
|
3
|
+
type WhereClauseV1 = components['schemas']['WhereClauseV1'];
|
|
4
|
+
type ConvertOptions = {
|
|
5
|
+
/** Internal flag to track if we're inside a logical operator (and/or) */
|
|
6
|
+
insideLogicalOperator?: boolean;
|
|
7
|
+
};
|
|
8
|
+
export declare function convertPayloadWhereToContentAPI(where: undefined | Where, options?: ConvertOptions): WhereClauseV1;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
export function convertPayloadWhereToContentAPI(where, options = {}) {
|
|
2
|
+
// Empty where {} should be { and: [] } not undefined
|
|
3
|
+
// Content API requires a where clause structure even for "no filter"
|
|
4
|
+
if (!where || Object.keys(where).length === 0) {
|
|
5
|
+
return {
|
|
6
|
+
and: []
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
const conditions = [];
|
|
10
|
+
for (const [key, value] of Object.entries(where)){
|
|
11
|
+
const keyLower = key.toLowerCase();
|
|
12
|
+
if (keyLower === 'and' || keyLower === 'or') {
|
|
13
|
+
const nestedConditions = value.map((item)=>convertPayloadWhereToContentAPI(item, {
|
|
14
|
+
...options,
|
|
15
|
+
insideLogicalOperator: true
|
|
16
|
+
})).filter((condition)=>{
|
|
17
|
+
if ('and' in condition) {
|
|
18
|
+
return condition.and.length > 0;
|
|
19
|
+
}
|
|
20
|
+
if ('or' in condition) {
|
|
21
|
+
return condition.or.length > 0;
|
|
22
|
+
}
|
|
23
|
+
return true;
|
|
24
|
+
});
|
|
25
|
+
if (keyLower === 'and') {
|
|
26
|
+
conditions.push(...nestedConditions);
|
|
27
|
+
} else if (nestedConditions.length > 0) {
|
|
28
|
+
conditions.push({
|
|
29
|
+
or: nestedConditions
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
} else {
|
|
33
|
+
const fieldPath = key.replace(/__/g, '.');
|
|
34
|
+
// Convert field conditions: { fieldName: { operator: value } }
|
|
35
|
+
// to: { path: fieldName, operator, value }
|
|
36
|
+
// Handle Payload's shorthand: { fieldName: value } → { fieldName: { equals: value } }
|
|
37
|
+
// If value is a primitive (string, number, boolean, null) or not a plain object,
|
|
38
|
+
// treat it as an implicit 'equals' operator
|
|
39
|
+
const isPrimitive = value === null || typeof value !== 'object' || Array.isArray(value);
|
|
40
|
+
if (isPrimitive) {
|
|
41
|
+
// Shorthand format: { id: "some-value" } means { id: { equals: "some-value" } }
|
|
42
|
+
conditions.push({
|
|
43
|
+
operator: 'equals',
|
|
44
|
+
path: fieldPath,
|
|
45
|
+
value: fieldPath === 'id' && typeof value === 'number' ? String(value) : value
|
|
46
|
+
});
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
const operators = value;
|
|
50
|
+
// Skip empty operator objects { fieldName: {} }
|
|
51
|
+
if (Object.keys(operators).length === 0) {
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
for (const [op, operatorValue] of Object.entries(operators)){
|
|
55
|
+
// Skip operators with undefined values (e.g., { equals: undefined })
|
|
56
|
+
// This can happen when Payload sends incomplete where clauses
|
|
57
|
+
if (operatorValue === undefined) {
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
let finalValue = operatorValue;
|
|
61
|
+
// Convert string booleans to actual booleans for exists operator
|
|
62
|
+
// REST API sends "true"/"false" as strings, but Content API requires boolean
|
|
63
|
+
if (op === 'exists' && typeof operatorValue === 'string') {
|
|
64
|
+
finalValue = operatorValue === 'true';
|
|
65
|
+
}
|
|
66
|
+
// REST API sends "null" as a string; convert to actual null
|
|
67
|
+
if (finalValue === 'null') {
|
|
68
|
+
finalValue = null;
|
|
69
|
+
}
|
|
70
|
+
// Content API stores all document IDs as strings.
|
|
71
|
+
// Payload sends numeric values for collections with custom numeric ID fields,
|
|
72
|
+
// so we must stringify to match.
|
|
73
|
+
if (fieldPath === 'id' && typeof finalValue === 'number') {
|
|
74
|
+
finalValue = String(finalValue);
|
|
75
|
+
}
|
|
76
|
+
conditions.push({
|
|
77
|
+
operator: op,
|
|
78
|
+
path: fieldPath,
|
|
79
|
+
value: finalValue
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if (conditions.length === 0) {
|
|
85
|
+
return {
|
|
86
|
+
and: []
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
if (options.insideLogicalOperator && conditions.length === 1) {
|
|
90
|
+
return conditions[0];
|
|
91
|
+
}
|
|
92
|
+
return {
|
|
93
|
+
and: conditions
|
|
94
|
+
};
|
|
95
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Config } from 'payload';
|
|
2
|
+
/**
|
|
3
|
+
* Payload plugin that extracts cron schedule metadata and writes
|
|
4
|
+
* `.next/static/payload-schedules.json` during `figma deploy` builds.
|
|
5
|
+
*
|
|
6
|
+
* Only runs when `FIGMA_EXTRACT_SCHEDULES=true`, which is set exclusively by
|
|
7
|
+
* the deploy CLI before spawning `next build`. At Lambda runtime and during
|
|
8
|
+
* local development the env var is absent and this plugin is a no-op.
|
|
9
|
+
*/
|
|
10
|
+
export declare function scheduleExtractPlugin(): (config: Config) => Config;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
/**
|
|
4
|
+
* Payload plugin that extracts cron schedule metadata and writes
|
|
5
|
+
* `.next/static/payload-schedules.json` during `figma deploy` builds.
|
|
6
|
+
*
|
|
7
|
+
* Only runs when `FIGMA_EXTRACT_SCHEDULES=true`, which is set exclusively by
|
|
8
|
+
* the deploy CLI before spawning `next build`. At Lambda runtime and during
|
|
9
|
+
* local development the env var is absent and this plugin is a no-op.
|
|
10
|
+
*/ export function scheduleExtractPlugin() {
|
|
11
|
+
return (config)=>{
|
|
12
|
+
if (process.env.FIGMA_EXTRACT_SCHEDULES !== 'true') {
|
|
13
|
+
return config;
|
|
14
|
+
}
|
|
15
|
+
const schedules = [
|
|
16
|
+
...(config.jobs?.tasks ?? []).flatMap((task)=>(task.schedule ?? []).map((sched)=>({
|
|
17
|
+
slug: task.slug,
|
|
18
|
+
cron: sched.cron
|
|
19
|
+
}))),
|
|
20
|
+
...(config.jobs?.workflows ?? []).flatMap((workflow)=>(workflow.schedule ?? []).map((sched)=>({
|
|
21
|
+
slug: workflow.slug,
|
|
22
|
+
cron: sched.cron
|
|
23
|
+
})))
|
|
24
|
+
];
|
|
25
|
+
const outDir = path.join(process.cwd(), '.next', 'static');
|
|
26
|
+
fs.mkdirSync(outDir, {
|
|
27
|
+
recursive: true
|
|
28
|
+
});
|
|
29
|
+
fs.writeFileSync(path.join(outDir, 'payload-schedules.json'), JSON.stringify(schedules));
|
|
30
|
+
return config;
|
|
31
|
+
};
|
|
32
|
+
}
|