@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 @@
|
|
|
1
|
+
export declare const getGlobalSlug: (slug: string) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const getGlobalSlug = (slug)=>`_global-${slug}`;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// Add fallback sort to ensure consistent ordering when sorting by non-unique fields
|
|
2
|
+
// Matches MongoDB adapter behavior
|
|
3
|
+
// If multiple collections are joined, we need to ensure fallback sort fields are consistent across them to avoid conflicts.
|
|
4
|
+
// If all collections have timestamps, use createdAt, otherwise use id.
|
|
5
|
+
// TO-DECIDE: Should this live here or in content-api?
|
|
6
|
+
export function addFallbackSort(sort, payload, collectionSlug, defaultSort) {
|
|
7
|
+
const collectionsArray = Array.isArray(collectionSlug) ? collectionSlug : [
|
|
8
|
+
collectionSlug
|
|
9
|
+
];
|
|
10
|
+
const collectionConfigs = collectionsArray.map((slug)=>payload.config.collections.find((c)=>c.slug === slug)).filter((collection)=>collection != null);
|
|
11
|
+
if (sort == null || collectionConfigs.length === 0) {
|
|
12
|
+
if (defaultSort) {
|
|
13
|
+
return addFallbackSort(defaultSort, payload, collectionSlug);
|
|
14
|
+
}
|
|
15
|
+
return sort;
|
|
16
|
+
}
|
|
17
|
+
const sortArray = Array.isArray(sort) ? sort : [
|
|
18
|
+
sort
|
|
19
|
+
];
|
|
20
|
+
// Determine fallback sort field
|
|
21
|
+
// If all collections have timestamps, use createdAt, otherwise use id
|
|
22
|
+
const fallbackSort = collectionConfigs.every((config)=>config.timestamps) ? '-createdAt' : '-id';
|
|
23
|
+
const fallbackInverse = fallbackSort.startsWith('-') ? fallbackSort.substring(1) : `-${fallbackSort}`;
|
|
24
|
+
// Check if fallback sort is already included
|
|
25
|
+
const hasFallback = sortArray.some((item)=>item === fallbackSort || item === fallbackInverse);
|
|
26
|
+
if (hasFallback) {
|
|
27
|
+
return sort;
|
|
28
|
+
}
|
|
29
|
+
// Check if all sort fields are unique (then no fallback needed)
|
|
30
|
+
// For simplicity, we'll always add fallback - checking uniqueness requires field traversal
|
|
31
|
+
// which would be expensive. This matches the conservative approach.
|
|
32
|
+
// Add fallback sort - always return array to preserve multiple sort fields
|
|
33
|
+
return [
|
|
34
|
+
...sortArray,
|
|
35
|
+
fallbackSort
|
|
36
|
+
];
|
|
37
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PathType can be either a simple string type or an object with additional metadata.
|
|
3
|
+
*
|
|
4
|
+
* Simple types: "array" - for array fields, blocks, or hasMany relationships/selects
|
|
5
|
+
*
|
|
6
|
+
* Relationship types include collection info needed for Content API to perform JOINs:
|
|
7
|
+
* - type: "relationship" for stored references, "join" for virtual reverse lookups
|
|
8
|
+
* - collection: target collection slug (or array for polymorphic)
|
|
9
|
+
* - hasMany: whether it stores multiple references
|
|
10
|
+
*
|
|
11
|
+
* TODO: This type is defined here temporarily so Content API can test the integration.
|
|
12
|
+
* Once Content API implements support for this, the type should be generated from openapi.json.
|
|
13
|
+
*/
|
|
14
|
+
export type PathTypeValue = 'array' | {
|
|
15
|
+
collection: string | string[];
|
|
16
|
+
hasMany?: boolean;
|
|
17
|
+
/** For join fields, the field path in the related collection that points back */
|
|
18
|
+
on?: string;
|
|
19
|
+
type: 'join' | 'relationship';
|
|
20
|
+
};
|
|
21
|
+
export type PathTypesRecord = Record<string, PathTypeValue>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PathType can be either a simple string type or an object with additional metadata.
|
|
3
|
+
*
|
|
4
|
+
* Simple types: "array" - for array fields, blocks, or hasMany relationships/selects
|
|
5
|
+
*
|
|
6
|
+
* Relationship types include collection info needed for Content API to perform JOINs:
|
|
7
|
+
* - type: "relationship" for stored references, "join" for virtual reverse lookups
|
|
8
|
+
* - collection: target collection slug (or array for polymorphic)
|
|
9
|
+
* - hasMany: whether it stores multiple references
|
|
10
|
+
*
|
|
11
|
+
* TODO: This type is defined here temporarily so Content API can test the integration.
|
|
12
|
+
* Once Content API implements support for this, the type should be generated from openapi.json.
|
|
13
|
+
*/ export { };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Payload } from 'payload';
|
|
2
|
+
import type { components } from '../generated/content-api-types.js';
|
|
3
|
+
type DocumentResponse = {
|
|
4
|
+
id: string;
|
|
5
|
+
} & components['schemas']['Document'];
|
|
6
|
+
type DocumentVersionResponse = {
|
|
7
|
+
id: string;
|
|
8
|
+
} & components['schemas']['DocumentVersion'];
|
|
9
|
+
export declare function unwrapDocument(args: {
|
|
10
|
+
collectionSlug?: string;
|
|
11
|
+
doc: DocumentResponse | DocumentVersionResponse;
|
|
12
|
+
locale?: string;
|
|
13
|
+
payload: Payload;
|
|
14
|
+
}): Record<string, unknown>;
|
|
15
|
+
export declare const unwrapFindResponse: (payload: Payload, response: components["schemas"]["FindDocumentsResponse"]["result"] | components["schemas"]["FindDocumentVersionsResponse"]["result"], collection: string, locale?: string) => {
|
|
16
|
+
totalDocs: number;
|
|
17
|
+
limit: number;
|
|
18
|
+
page: number;
|
|
19
|
+
totalPages: number;
|
|
20
|
+
pagingCounter: number;
|
|
21
|
+
hasPrevPage: boolean;
|
|
22
|
+
hasNextPage: boolean;
|
|
23
|
+
prevPage: number | null;
|
|
24
|
+
nextPage: number | null;
|
|
25
|
+
docs: Record<string, unknown>[];
|
|
26
|
+
} | {
|
|
27
|
+
totalDocs: number;
|
|
28
|
+
limit: number;
|
|
29
|
+
page: number;
|
|
30
|
+
totalPages: number;
|
|
31
|
+
pagingCounter: number;
|
|
32
|
+
hasPrevPage: boolean;
|
|
33
|
+
hasNextPage: boolean;
|
|
34
|
+
prevPage: number | null;
|
|
35
|
+
nextPage: number | null;
|
|
36
|
+
docs: Record<string, unknown>[];
|
|
37
|
+
};
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { dataFromContentAPI } from '../utilities/data/index.js';
|
|
2
|
+
// Helper to unwrap Content API document format to Payload format
|
|
3
|
+
// Content API returns:
|
|
4
|
+
// - For documents: { id, contentSystemId, collection, doc: { ...fields, createdAt, updatedAt } }
|
|
5
|
+
// - For versions: { id, contentSystemId, collection, versionDoc: { id, createdAt, updatedAt, latest, parent, version: {...fields} } }
|
|
6
|
+
// Payload expects:
|
|
7
|
+
// - For documents: { id, ...fields, createdAt, updatedAt }
|
|
8
|
+
// - For versions: { id, parent, latest, version: { ...fields }, createdAt, updatedAt }
|
|
9
|
+
export function unwrapDocument(args) {
|
|
10
|
+
const { collectionSlug, doc, locale, payload } = args;
|
|
11
|
+
if (!doc) {
|
|
12
|
+
return doc;
|
|
13
|
+
}
|
|
14
|
+
// Check if this is a DocumentVersion (has versionDoc field)
|
|
15
|
+
const isVersion = 'versionDoc' in doc;
|
|
16
|
+
if (isVersion) {
|
|
17
|
+
// For versions, Payload expects nested structure with 'version' field
|
|
18
|
+
const { versionDoc } = doc;
|
|
19
|
+
const baseDoc = {
|
|
20
|
+
...versionDoc
|
|
21
|
+
};
|
|
22
|
+
const versionData = baseDoc.version;
|
|
23
|
+
if (versionData && '_payloadAutosave' in versionData) {
|
|
24
|
+
baseDoc.autosave = versionData._payloadAutosave;
|
|
25
|
+
delete versionData._payloadAutosave;
|
|
26
|
+
}
|
|
27
|
+
// Transform data from Content API format to Payload format
|
|
28
|
+
if (collectionSlug) {
|
|
29
|
+
// Only transform the nested 'version' field
|
|
30
|
+
baseDoc.version = dataFromContentAPI(payload, collectionSlug, baseDoc.version, locale);
|
|
31
|
+
// Also convert version ID if collection uses numeric custom ID
|
|
32
|
+
const customIDType = payload.collections?.[collectionSlug]?.customIDType;
|
|
33
|
+
if (customIDType === 'number') {
|
|
34
|
+
baseDoc.id = Number(baseDoc.id);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return baseDoc;
|
|
38
|
+
}
|
|
39
|
+
// For regular documents, spread doc data at root level
|
|
40
|
+
const { id, doc: docData } = doc;
|
|
41
|
+
const baseDoc = {
|
|
42
|
+
...docData,
|
|
43
|
+
id
|
|
44
|
+
};
|
|
45
|
+
// Transform data from Content API format to Payload format
|
|
46
|
+
if (collectionSlug) {
|
|
47
|
+
return dataFromContentAPI(payload, collectionSlug, baseDoc, locale);
|
|
48
|
+
}
|
|
49
|
+
return baseDoc;
|
|
50
|
+
}
|
|
51
|
+
export const unwrapFindResponse = (payload, response, collection, locale)=>{
|
|
52
|
+
const { data, ...paginationFields } = response;
|
|
53
|
+
return {
|
|
54
|
+
docs: data.map((doc)=>unwrapDocument({
|
|
55
|
+
collectionSlug: collection,
|
|
56
|
+
doc: doc,
|
|
57
|
+
locale,
|
|
58
|
+
payload
|
|
59
|
+
})),
|
|
60
|
+
...paginationFields
|
|
61
|
+
};
|
|
62
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Middleware } from 'openapi-fetch';
|
|
2
|
+
import type { Payload } from 'payload';
|
|
3
|
+
import type { TokenStore } from '../../auth/token-store.js';
|
|
4
|
+
type ApiKeyAuth = {
|
|
5
|
+
apiKey: string;
|
|
6
|
+
mode: 'apiKey';
|
|
7
|
+
};
|
|
8
|
+
type TokenStoreAuth = {
|
|
9
|
+
mode: 'tokenStore';
|
|
10
|
+
tokenStore: TokenStore;
|
|
11
|
+
};
|
|
12
|
+
type DevJwtAuth = {
|
|
13
|
+
mode: 'devJwt';
|
|
14
|
+
};
|
|
15
|
+
export type AuthMode = ApiKeyAuth | DevJwtAuth | TokenStoreAuth;
|
|
16
|
+
export declare function fetchDevJwt(url: string, contentSystemId: string): Promise<string>;
|
|
17
|
+
export declare function createAuthMiddleware(opts: {
|
|
18
|
+
auth: AuthMode;
|
|
19
|
+
contentSystemId: string;
|
|
20
|
+
logger: Payload['logger'];
|
|
21
|
+
url: string;
|
|
22
|
+
}): Middleware;
|
|
23
|
+
export declare function createErrorMiddleware(opts: {
|
|
24
|
+
auth: AuthMode;
|
|
25
|
+
contentSystemId: string;
|
|
26
|
+
logger: Payload['logger'];
|
|
27
|
+
url: string;
|
|
28
|
+
}): Middleware;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { getValidProjectToken } from '../../auth/project-token.js';
|
|
2
|
+
// Module-level cache for dev JWT tokens
|
|
3
|
+
const devJwtCache = new Map();
|
|
4
|
+
export async function fetchDevJwt(url, contentSystemId) {
|
|
5
|
+
const usesSuperUser = !contentSystemId || contentSystemId === 'test-system' || contentSystemId === '*';
|
|
6
|
+
const contentSystemIdForJWT = usesSuperUser ? '*' : contentSystemId;
|
|
7
|
+
const response = await fetch(`${url}/dev/jwt`, {
|
|
8
|
+
body: JSON.stringify({
|
|
9
|
+
content_system_id: contentSystemIdForJWT
|
|
10
|
+
}),
|
|
11
|
+
headers: {
|
|
12
|
+
'Content-Type': 'application/json'
|
|
13
|
+
},
|
|
14
|
+
method: 'POST'
|
|
15
|
+
});
|
|
16
|
+
if (!response.ok) {
|
|
17
|
+
throw new Error(`Failed to get dev JWT: ${response.status} ${response.statusText}`);
|
|
18
|
+
}
|
|
19
|
+
const { token } = await response.json();
|
|
20
|
+
return token;
|
|
21
|
+
}
|
|
22
|
+
export function createAuthMiddleware(opts) {
|
|
23
|
+
return {
|
|
24
|
+
async onRequest ({ request }) {
|
|
25
|
+
if (opts.auth.mode === 'apiKey') {
|
|
26
|
+
request.headers.set('X-Api-Key', opts.auth.apiKey);
|
|
27
|
+
} else if (opts.auth.mode === 'tokenStore') {
|
|
28
|
+
const token = await getValidProjectToken({
|
|
29
|
+
tenantId: opts.contentSystemId,
|
|
30
|
+
tokenStore: opts.auth.tokenStore
|
|
31
|
+
});
|
|
32
|
+
if (!token) {
|
|
33
|
+
throw new Error('Authentication required. Run `npx @payloadcms/figma login` to authenticate.');
|
|
34
|
+
}
|
|
35
|
+
request.headers.set('Authorization', `Bearer ${token}`);
|
|
36
|
+
} else {
|
|
37
|
+
let token = devJwtCache.get(opts.contentSystemId);
|
|
38
|
+
if (!token) {
|
|
39
|
+
token = await fetchDevJwt(opts.url, opts.contentSystemId);
|
|
40
|
+
devJwtCache.set(opts.contentSystemId, token);
|
|
41
|
+
opts.logger.info(`Dev JWT acquired for content system: ${opts.contentSystemId}`);
|
|
42
|
+
}
|
|
43
|
+
request.headers.set('Authorization', `Bearer ${token}`);
|
|
44
|
+
}
|
|
45
|
+
return request;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
export function createErrorMiddleware(opts) {
|
|
50
|
+
return {
|
|
51
|
+
async onResponse ({ request, response }) {
|
|
52
|
+
if (!response.ok) {
|
|
53
|
+
// Handle 401 retry for dev JWT
|
|
54
|
+
if (response.status === 401 && opts.auth.mode === 'devJwt') {
|
|
55
|
+
const retryCount = parseInt(request.headers.get('X-Retry-Count') || '0', 10);
|
|
56
|
+
if (retryCount < 1) {
|
|
57
|
+
opts.logger.info('Dev JWT expired, refreshing...');
|
|
58
|
+
devJwtCache.delete(opts.contentSystemId);
|
|
59
|
+
const newToken = await fetchDevJwt(opts.url, opts.contentSystemId);
|
|
60
|
+
devJwtCache.set(opts.contentSystemId, newToken);
|
|
61
|
+
// duplex: 'half' is required for Node.js fetch with streaming body
|
|
62
|
+
const newRequest = new Request(request.url, {
|
|
63
|
+
body: request.body,
|
|
64
|
+
duplex: 'half',
|
|
65
|
+
headers: new Headers(request.headers),
|
|
66
|
+
method: request.method
|
|
67
|
+
});
|
|
68
|
+
newRequest.headers.set('X-Retry-Count', '1');
|
|
69
|
+
newRequest.headers.set('Authorization', `Bearer ${newToken}`);
|
|
70
|
+
return fetch(newRequest);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
const text = await response.clone().text();
|
|
74
|
+
opts.logger.error({
|
|
75
|
+
msg: `HTTP ${response.status} from ${request.url}`,
|
|
76
|
+
response: text
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
return response;
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const FIGMA_PAYLOAD_PLUGIN_VERSION_HEADER = "X-Figma-Payload-Plugin-Version";
|
|
2
|
+
type ClientVersionHeadersArgs = {
|
|
3
|
+
payloadPluginVersion: string;
|
|
4
|
+
};
|
|
5
|
+
export declare function getClientVersionHeaders(): Record<string, string>;
|
|
6
|
+
export declare function buildClientVersionHeaders({ payloadPluginVersion, }: ClientVersionHeadersArgs): Record<string, string>;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import packageJson from '../../../package.json' with {
|
|
2
|
+
type: 'json'
|
|
3
|
+
};
|
|
4
|
+
// KEEP_IN_SYNC(payload/content-api/src/server/clientVersionTelemetry.ts)
|
|
5
|
+
export const FIGMA_PAYLOAD_PLUGIN_VERSION_HEADER = 'X-Figma-Payload-Plugin-Version';
|
|
6
|
+
export function getClientVersionHeaders() {
|
|
7
|
+
return buildClientVersionHeaders({
|
|
8
|
+
payloadPluginVersion: packageJson.version
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
export function buildClientVersionHeaders({ payloadPluginVersion }) {
|
|
12
|
+
return {
|
|
13
|
+
[FIGMA_PAYLOAD_PLUGIN_VERSION_HEADER]: payloadPluginVersion
|
|
14
|
+
};
|
|
15
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Field, FlattenedBlock } from 'payload';
|
|
2
|
+
/**
|
|
3
|
+
* Recursively apply static default values to data
|
|
4
|
+
* This handles defaults for nested structures (arrays, groups) which traverseFields doesn't handle
|
|
5
|
+
*/
|
|
6
|
+
export declare function applyDefaults(data: Record<string, unknown>, fields: Field[], configBlocks?: FlattenedBlock[]): void;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { resolveBlocks } from '../resolveBlocks.js';
|
|
2
|
+
/**
|
|
3
|
+
* Recursively apply static default values to data
|
|
4
|
+
* This handles defaults for nested structures (arrays, groups) which traverseFields doesn't handle
|
|
5
|
+
*/ export function applyDefaults(data, fields, configBlocks) {
|
|
6
|
+
for (const field of fields){
|
|
7
|
+
// Tabs fields: unnamed tabs are transparent (fields at the same level); named tabs nest
|
|
8
|
+
// their fields under the tab's name key. Recurse before the name-based guard so
|
|
9
|
+
// tab-nested fields (e.g. hasError in payload-jobs) get their defaults applied.
|
|
10
|
+
if (field.type === 'tabs') {
|
|
11
|
+
for (const tab of field.tabs){
|
|
12
|
+
if ('name' in tab && tab.name) {
|
|
13
|
+
if (!data[tab.name]) {
|
|
14
|
+
data[tab.name] = {};
|
|
15
|
+
}
|
|
16
|
+
applyDefaults(data[tab.name], tab.fields, configBlocks);
|
|
17
|
+
} else {
|
|
18
|
+
applyDefaults(data, tab.fields, configBlocks);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
// Only process fields that affect data (have a name)
|
|
24
|
+
if (!('name' in field) || !field.name) {
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
const value = data[field.name];
|
|
28
|
+
// Check if field has a default value (only for FieldAffectingData types)
|
|
29
|
+
const defaultValue = 'defaultValue' in field ? field.defaultValue : undefined;
|
|
30
|
+
const hasDefault = defaultValue !== undefined;
|
|
31
|
+
const isFunction = typeof defaultValue === 'function';
|
|
32
|
+
// Skip function defaults - they need req/user context
|
|
33
|
+
if (hasDefault && isFunction) {
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
// Apply default if value is undefined
|
|
37
|
+
if (hasDefault && value === undefined) {
|
|
38
|
+
let appliedDefault = typeof defaultValue === 'object' ? JSON.parse(JSON.stringify(defaultValue)) : defaultValue;
|
|
39
|
+
// Special handling for point fields: convert array [lng, lat] to GeoJSON format
|
|
40
|
+
if (field.type === 'point' && Array.isArray(appliedDefault) && appliedDefault.length === 2) {
|
|
41
|
+
appliedDefault = {
|
|
42
|
+
type: 'Point',
|
|
43
|
+
coordinates: appliedDefault
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
data[field.name] = appliedDefault;
|
|
47
|
+
}
|
|
48
|
+
// Recursively process nested structures
|
|
49
|
+
const currentValue = data[field.name];
|
|
50
|
+
if (field.type === 'array' && Array.isArray(currentValue) && 'fields' in field) {
|
|
51
|
+
// Apply defaults to each array element
|
|
52
|
+
for (const element of currentValue){
|
|
53
|
+
if (element && typeof element === 'object') {
|
|
54
|
+
applyDefaults(element, field.fields, configBlocks);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
} else if (field.type === 'group' && 'fields' in field) {
|
|
58
|
+
if (currentValue == null || typeof currentValue !== 'object') {
|
|
59
|
+
data[field.name] = {};
|
|
60
|
+
}
|
|
61
|
+
applyDefaults(data[field.name], field.fields, configBlocks);
|
|
62
|
+
} else if (field.type === 'blocks' && Array.isArray(currentValue) && 'blocks' in field) {
|
|
63
|
+
const resolvedBlocks = resolveBlocks(field.blocks, configBlocks);
|
|
64
|
+
// Apply defaults to each block
|
|
65
|
+
for (const element of currentValue){
|
|
66
|
+
if (element && typeof element === 'object' && 'blockType' in element) {
|
|
67
|
+
const block = resolvedBlocks.find((b)=>b.slug === element.blockType);
|
|
68
|
+
if (block?.fields) {
|
|
69
|
+
applyDefaults(element, block.fields, configBlocks);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type AtomicOperator = '$inc' | '$push' | '$remove';
|
|
2
|
+
export declare const ATOMIC_OPERATORS: readonly AtomicOperator[];
|
|
3
|
+
/** Relationship/upload values are lists, so they only ever carry list operators. */
|
|
4
|
+
export declare const RELATIONSHIP_ATOMIC_OPERATORS: readonly ('$push' | '$remove')[];
|
|
5
|
+
/**
|
|
6
|
+
* Recognizes an atomic-operation wrapper, returning its operator and the wrapped
|
|
7
|
+
* value, or `null` when the value is not such a wrapper.
|
|
8
|
+
*/
|
|
9
|
+
export declare function matchAtomicOperation<T extends AtomicOperator>(value: unknown, operators: readonly T[]): {
|
|
10
|
+
inner: unknown;
|
|
11
|
+
operator: T;
|
|
12
|
+
} | null;
|
|
13
|
+
/** Whether the value is an atomic-operation wrapper rather than a plain value. */
|
|
14
|
+
export declare function isAtomicOperation(value: unknown, operators: readonly AtomicOperator[]): boolean;
|
|
15
|
+
/** Returns the wrapped value of an atomic operation, or the value itself. */
|
|
16
|
+
export declare function unwrapAtomicOperation(value: unknown, operators: readonly AtomicOperator[]): unknown;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// Payload expresses an atomic field update as a single-key wrapper around the
|
|
2
|
+
// value — e.g. `{ $push: ['id'] }` on a has-many relationship, `{ $inc: 1 }` on a
|
|
3
|
+
// number field. Which operators are legal depends on the field type, so callers
|
|
4
|
+
// pass the set they accept; the default is every operator the adapter knows about.
|
|
5
|
+
export const ATOMIC_OPERATORS = [
|
|
6
|
+
'$inc',
|
|
7
|
+
'$push',
|
|
8
|
+
'$remove'
|
|
9
|
+
];
|
|
10
|
+
/** Relationship/upload values are lists, so they only ever carry list operators. */ export const RELATIONSHIP_ATOMIC_OPERATORS = [
|
|
11
|
+
'$push',
|
|
12
|
+
'$remove'
|
|
13
|
+
];
|
|
14
|
+
/**
|
|
15
|
+
* Recognizes an atomic-operation wrapper, returning its operator and the wrapped
|
|
16
|
+
* value, or `null` when the value is not such a wrapper.
|
|
17
|
+
*/ export function matchAtomicOperation(value, operators) {
|
|
18
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
const keys = Object.keys(value);
|
|
22
|
+
if (keys.length !== 1) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
const key = keys[0];
|
|
26
|
+
if (!isOneOf(key, operators)) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
inner: value[key],
|
|
31
|
+
operator: key
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/** Whether the value is an atomic-operation wrapper rather than a plain value. */ export function isAtomicOperation(value, operators) {
|
|
35
|
+
return matchAtomicOperation(value, operators) !== null;
|
|
36
|
+
}
|
|
37
|
+
/** Returns the wrapped value of an atomic operation, or the value itself. */ export function unwrapAtomicOperation(value, operators) {
|
|
38
|
+
const match = matchAtomicOperation(value, operators);
|
|
39
|
+
return match ? match.inner : value;
|
|
40
|
+
}
|
|
41
|
+
function isOneOf(value, options) {
|
|
42
|
+
for (const option of options){
|
|
43
|
+
if (option === value) {
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Field, TabAsField } from 'payload';
|
|
2
|
+
/**
|
|
3
|
+
* Cast field values to the appropriate type for Content API storage.
|
|
4
|
+
*
|
|
5
|
+
* This function implements type coercion similar to Mongoose (used by MongoDB adapter)
|
|
6
|
+
* to ensure data consistency. When users ignore TypeScript types and pass incorrect types,
|
|
7
|
+
* we automatically convert them to the expected type.
|
|
8
|
+
*
|
|
9
|
+
*/
|
|
10
|
+
export declare function castFieldValue(field: Field | TabAsField, value: unknown): unknown;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cast field values to the appropriate type for Content API storage.
|
|
3
|
+
*
|
|
4
|
+
* This function implements type coercion similar to Mongoose (used by MongoDB adapter)
|
|
5
|
+
* to ensure data consistency. When users ignore TypeScript types and pass incorrect types,
|
|
6
|
+
* we automatically convert them to the expected type.
|
|
7
|
+
*
|
|
8
|
+
*/ export function castFieldValue(field, value) {
|
|
9
|
+
if (value === null || value === undefined) {
|
|
10
|
+
return value;
|
|
11
|
+
}
|
|
12
|
+
if (field.type === 'number') {
|
|
13
|
+
if ('hasMany' in field && field.hasMany && Array.isArray(value)) {
|
|
14
|
+
return value.map((item)=>{
|
|
15
|
+
if (typeof item === 'number') {
|
|
16
|
+
return item;
|
|
17
|
+
}
|
|
18
|
+
if (typeof item === 'string' || typeof item === 'boolean') {
|
|
19
|
+
return Number(item);
|
|
20
|
+
}
|
|
21
|
+
return item;
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
if (typeof value !== 'number') {
|
|
25
|
+
if (typeof value === 'string' || typeof value === 'boolean') {
|
|
26
|
+
return Number(value);
|
|
27
|
+
}
|
|
28
|
+
return value;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (field.type === 'checkbox' && typeof value !== 'boolean') {
|
|
32
|
+
// Localized fields store locale-keyed objects like { en: true } — don't cast
|
|
33
|
+
if ('localized' in field && field.localized && typeof value === 'object' && value !== null) {
|
|
34
|
+
return value;
|
|
35
|
+
}
|
|
36
|
+
if (typeof value === 'string') {
|
|
37
|
+
if (value.toLowerCase() === 'true' || value === '1') {
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
if (value.toLowerCase() === 'false' || value === '0' || value === '') {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return Boolean(value);
|
|
45
|
+
}
|
|
46
|
+
// Matches Mongoose behavior: stores dates as ISO strings
|
|
47
|
+
if (field.type === 'date' && typeof value !== 'string') {
|
|
48
|
+
// Localized fields store locale-keyed objects like { en: '2024-01-01' } — don't cast
|
|
49
|
+
if ('localized' in field && field.localized && typeof value === 'object' && value !== null) {
|
|
50
|
+
return value;
|
|
51
|
+
}
|
|
52
|
+
if (value instanceof Date) {
|
|
53
|
+
return value.toISOString();
|
|
54
|
+
}
|
|
55
|
+
if (typeof value === 'number') {
|
|
56
|
+
return new Date(value).toISOString();
|
|
57
|
+
}
|
|
58
|
+
return value;
|
|
59
|
+
}
|
|
60
|
+
// Text-like fields: convert non-strings to JSON strings.
|
|
61
|
+
// Exceptions: localized (stored as locale map) and hasMany (stored as array).
|
|
62
|
+
if ((field.type === 'text' || field.type === 'textarea' || field.type === 'email' || field.type === 'code') && typeof value !== 'string' && !('localized' in field && field.localized) && !('hasMany' in field && field.hasMany && Array.isArray(value))) {
|
|
63
|
+
return JSON.stringify(value);
|
|
64
|
+
}
|
|
65
|
+
return value;
|
|
66
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Payload, RelationshipField, UploadField } from 'payload';
|
|
2
|
+
type Direction = 'fromWire' | 'toWire';
|
|
3
|
+
export declare function convertRelationshipFieldIdsFromWire(options: {
|
|
4
|
+
field: RelationshipField | UploadField;
|
|
5
|
+
payload: Payload;
|
|
6
|
+
value: unknown;
|
|
7
|
+
}): unknown;
|
|
8
|
+
export declare function convertRelationshipFieldIdsToWire(options: {
|
|
9
|
+
field: RelationshipField | UploadField;
|
|
10
|
+
payload: Payload;
|
|
11
|
+
value: unknown;
|
|
12
|
+
}): unknown;
|
|
13
|
+
/**
|
|
14
|
+
* Converts the id(s) inside a relationship/upload field value between Payload's
|
|
15
|
+
* representation (numeric ids kept as numbers) and the Content API wire form
|
|
16
|
+
* (all ids as strings). No-op for uuid/text targets. Preserves has-many arrays,
|
|
17
|
+
* polymorphic shapes, localized locale-maps, and atomic operators.
|
|
18
|
+
*/
|
|
19
|
+
export declare function convertRelationshipFieldIds(options: {
|
|
20
|
+
direction: Direction;
|
|
21
|
+
field: RelationshipField | UploadField;
|
|
22
|
+
payload: Payload;
|
|
23
|
+
value: unknown;
|
|
24
|
+
}): unknown;
|
|
25
|
+
export {};
|