@payloadcms/figma 0.0.1-alpha.7 → 0.0.1-alpha.70
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/control-plane.d.ts +56 -6
- package/dist/api/control-plane.js +181 -72
- package/dist/api/figma-api.d.ts +22 -1
- package/dist/api/figma-api.js +78 -25
- package/dist/auth/callback-server.d.ts +19 -7
- package/dist/auth/callback-server.js +72 -30
- package/dist/auth/credentials.d.ts +21 -0
- package/dist/auth/credentials.js +21 -0
- package/dist/auth/crypto-utils.d.ts +28 -0
- package/dist/auth/crypto-utils.js +132 -21
- package/dist/auth/jwt-validator.d.ts +2 -1
- package/dist/auth/jwt-validator.js +2 -2
- package/dist/auth/oauth-flow.d.ts +19 -3
- package/dist/auth/oauth-flow.js +77 -22
- package/dist/auth/project-token.d.ts +32 -16
- package/dist/auth/project-token.js +171 -65
- package/dist/auth/refresh.d.ts +2 -1
- package/dist/auth/refresh.js +25 -12
- package/dist/auth/token-store-migration.d.ts +58 -0
- package/dist/auth/token-store-migration.js +156 -0
- package/dist/auth/token-store.d.ts +63 -97
- package/dist/auth/token-store.js +405 -122
- package/dist/auth/types.d.ts +35 -4
- package/dist/cli.js +93 -6
- package/dist/commands/bootstrap.d.ts +18 -0
- package/dist/commands/bootstrap.js +90 -0
- package/dist/commands/build-lambda-zip.d.ts +5 -0
- package/dist/commands/build-lambda-zip.js +19 -0
- package/dist/commands/debug.d.ts +8 -0
- package/dist/commands/debug.js +180 -0
- package/dist/commands/deploy.d.ts +9 -0
- package/dist/commands/deploy.js +180 -151
- package/dist/commands/dump-tokens.d.ts +12 -0
- package/dist/commands/dump-tokens.js +69 -0
- package/dist/commands/env.d.ts +13 -0
- package/dist/commands/env.js +88 -0
- package/dist/commands/init.d.ts +9 -5
- package/dist/commands/init.js +241 -148
- package/dist/commands/list-tokens.d.ts +3 -3
- package/dist/commands/list-tokens.js +24 -9
- package/dist/commands/login.d.ts +8 -1
- package/dist/commands/login.js +34 -16
- package/dist/commands/logout.d.ts +5 -4
- package/dist/commands/logout.js +77 -15
- package/dist/commands/upgrade.d.ts +5 -0
- package/dist/commands/upgrade.js +331 -0
- package/dist/config/oauth.d.ts +17 -11
- package/dist/config/oauth.js +38 -37
- package/dist/constants.d.ts +63 -18
- package/dist/constants.js +158 -18
- package/dist/db-content-api/generated/content-api-types.d.ts +3978 -0
- package/dist/db-content-api/generated/content-api-types.js +7 -0
- package/dist/db-content-api/index.d.ts +37 -0
- package/dist/db-content-api/index.js +923 -0
- package/dist/db-content-api/temp-utilities/slug.d.ts +2 -0
- package/dist/db-content-api/temp-utilities/slug.js +3 -0
- package/dist/db-content-api/temp-utilities/sorting.d.ts +3 -0
- package/dist/db-content-api/temp-utilities/sorting.js +39 -0
- package/dist/db-content-api/temp-utilities/types.d.ts +22 -0
- package/dist/db-content-api/temp-utilities/types.js +15 -0
- package/dist/db-content-api/temp-utilities/unwrapDocument.d.ts +39 -0
- package/dist/db-content-api/temp-utilities/unwrapDocument.js +64 -0
- package/dist/db-content-api/utilities/auth.d.ts +30 -0
- package/dist/db-content-api/utilities/auth.js +84 -0
- package/dist/db-content-api/utilities/data/applyDefaults.d.ts +7 -0
- package/dist/db-content-api/utilities/data/applyDefaults.js +75 -0
- package/dist/db-content-api/utilities/data/castFieldValue.d.ts +11 -0
- package/dist/db-content-api/utilities/data/castFieldValue.js +68 -0
- package/dist/db-content-api/utilities/data/index.d.ts +49 -0
- package/dist/db-content-api/utilities/data/index.js +301 -0
- package/dist/db-content-api/utilities/data/removeVirtualFields.d.ts +12 -0
- package/dist/db-content-api/utilities/data/removeVirtualFields.js +54 -0
- package/dist/db-content-api/utilities/data/stripFields.d.ts +48 -0
- package/dist/db-content-api/utilities/data/stripFields.js +195 -0
- package/dist/db-content-api/utilities/data/transformPublishedLocale.d.ts +23 -0
- package/dist/db-content-api/utilities/data/transformPublishedLocale.js +42 -0
- package/dist/db-content-api/utilities/data/validateRelationships.d.ts +7 -0
- package/dist/db-content-api/utilities/data/validateRelationships.js +102 -0
- package/dist/db-content-api/utilities/joins.d.ts +53 -0
- package/dist/db-content-api/utilities/joins.js +139 -0
- package/dist/db-content-api/utilities/locale/index.d.ts +10 -0
- package/dist/db-content-api/utilities/locale/index.js +21 -0
- package/dist/db-content-api/utilities/meta/buildLocalizedPaths.d.ts +11 -0
- package/dist/db-content-api/utilities/meta/buildLocalizedPaths.js +74 -0
- package/dist/db-content-api/utilities/meta/buildMeta.d.ts +42 -0
- package/dist/db-content-api/utilities/meta/buildMeta.js +41 -0
- package/dist/db-content-api/utilities/meta/buildPathTypes.d.ts +17 -0
- package/dist/db-content-api/utilities/meta/buildPathTypes.js +244 -0
- package/dist/db-content-api/utilities/meta/buildUniquePaths.d.ts +13 -0
- package/dist/db-content-api/utilities/meta/buildUniquePaths.js +62 -0
- package/dist/db-content-api/utilities/meta/normalizeLocaleInWhere.d.ts +10 -0
- package/dist/db-content-api/utilities/meta/normalizeLocaleInWhere.js +102 -0
- package/dist/db-content-api/utilities/where.d.ts +20 -0
- package/dist/db-content-api/utilities/where.js +108 -0
- package/dist/deploy/schedule-extract-plugin.d.ts +11 -0
- package/dist/deploy/schedule-extract-plugin.js +34 -0
- package/dist/endpoints/health.d.ts +3 -0
- package/dist/endpoints/health.js +11 -0
- package/dist/endpoints/schema.d.ts +3 -0
- package/dist/endpoints/schema.js +29 -0
- package/dist/exports/client.d.ts +3 -0
- package/dist/exports/client.js +3 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3 -1
- package/dist/lib/download-skill.d.ts +13 -0
- package/dist/lib/download-skill.js +79 -0
- package/dist/oauth/components/FigmaAvatar/index.d.ts +4 -0
- package/dist/oauth/components/FigmaAvatar/index.js +27 -0
- package/dist/oauth/components/FigmaAvatar/index.scss +12 -0
- package/dist/oauth/components/FigmaAvatarCell/index.d.ts +5 -0
- package/dist/oauth/components/FigmaAvatarCell/index.js +25 -0
- package/dist/oauth/components/FigmaAvatarCell/index.scss +5 -0
- package/dist/oauth/components/FigmaAvatarPlaceholder/index.d.ts +9 -0
- package/dist/oauth/components/FigmaAvatarPlaceholder/index.js +37 -0
- package/dist/oauth/components/FigmaAvatarPlaceholder/index.scss +28 -0
- package/dist/oauth/components/LoginButton/iframeAutoLogin.d.ts +82 -0
- package/dist/oauth/components/LoginButton/iframeAutoLogin.js +170 -0
- package/dist/oauth/components/LoginButton/index.js +144 -11
- package/dist/oauth/components/LoginButton/index.scss +75 -3
- package/dist/oauth/components/LogoutButton/index.js +19 -6
- package/dist/oauth/defaults.d.ts +3 -1
- package/dist/oauth/defaults.js +68 -10
- package/dist/oauth/endpoints/getLoginEndpoint.js +72 -77
- package/dist/oauth/endpoints/getLogoutEndpoint.js +7 -4
- package/dist/oauth/endpoints/getMetaEndpoint.js +18 -3
- package/dist/oauth/endpoints/getRedirectToLoginEndpoint.js +11 -2
- package/dist/oauth/index.js +27 -5
- package/dist/oauth/strategy/index.d.ts +0 -2
- package/dist/oauth/strategy/index.js +40 -17
- package/dist/oauth/types.d.ts +23 -6
- package/dist/oauth/utilities/establishSession.d.ts +23 -0
- package/dist/oauth/utilities/establishSession.js +82 -0
- package/dist/oauth/utilities/exchangeCodeForAccessToken.d.ts +24 -0
- package/dist/oauth/utilities/exchangeCodeForAccessToken.js +28 -0
- package/dist/oauth/utilities/figmaHostnames.d.ts +3 -0
- package/dist/oauth/utilities/figmaHostnames.js +26 -0
- package/dist/oauth/utilities/getAuthorizeURL.d.ts +65 -1
- package/dist/oauth/utilities/getAuthorizeURL.js +57 -2
- package/dist/oauth/utilities/isAbsoluteURL.d.ts +2 -0
- package/dist/oauth/utilities/isAbsoluteURL.js +3 -0
- package/dist/oauth/utilities/isDuplicateKeyError.d.ts +7 -0
- package/dist/oauth/utilities/isDuplicateKeyError.js +14 -0
- package/dist/oauth/utilities/refreshTokens.js +6 -3
- package/dist/plugin/auth-preflight.d.ts +8 -0
- package/dist/plugin/auth-preflight.js +20 -0
- package/dist/plugin/bootstrap-preflight.d.ts +23 -0
- package/dist/plugin/bootstrap-preflight.js +45 -0
- package/dist/plugin/build-config.d.ts +27 -15
- package/dist/plugin/build-config.js +327 -17
- package/dist/plugin/dev-cookie-names.d.ts +14 -0
- package/dist/plugin/dev-cookie-names.js +19 -0
- package/dist/storage-content-api/api-types.d.ts +168 -0
- package/dist/storage-content-api/api-types.js +6 -0
- package/dist/storage-content-api/client-uploads/ClientUploadHandler.d.ts +9 -0
- package/dist/storage-content-api/client-uploads/ClientUploadHandler.js +43 -0
- package/dist/storage-content-api/client-uploads/generateSignedURL.d.ts +13 -0
- package/dist/storage-content-api/client-uploads/generateSignedURL.js +39 -0
- package/dist/storage-content-api/client.d.ts +6 -0
- package/dist/storage-content-api/client.js +39 -0
- package/dist/storage-content-api/generateURL.d.ts +7 -0
- package/dist/storage-content-api/generateURL.js +8 -0
- package/dist/storage-content-api/handleDelete.d.ts +8 -0
- package/dist/storage-content-api/handleDelete.js +17 -0
- package/dist/storage-content-api/handleUpload.d.ts +11 -0
- package/dist/storage-content-api/handleUpload.js +144 -0
- package/dist/storage-content-api/index.d.ts +5 -0
- package/dist/storage-content-api/index.js +31 -0
- package/dist/storage-content-api/staticHandler.d.ts +10 -0
- package/dist/storage-content-api/staticHandler.js +63 -0
- package/dist/storage-content-api/types.d.ts +10 -0
- package/dist/storage-content-api/types.js +3 -0
- package/dist/storage-content-api/utilities/getSafeFilename.d.ts +12 -0
- package/dist/storage-content-api/utilities/getSafeFilename.js +61 -0
- package/dist/storage-content-api/utilities/index.d.ts +3 -0
- package/dist/storage-content-api/utilities/index.js +4 -0
- package/dist/storage-content-api/utilities/parseClientUploadContext.d.ts +19 -0
- package/dist/storage-content-api/utilities/parseClientUploadContext.js +30 -0
- package/dist/templates/.env.example +5 -0
- package/dist/templates/README.md +19 -0
- package/dist/types/config.d.ts +2 -1
- package/dist/types/config.js +0 -2
- package/dist/types.d.ts +10 -1
- package/dist/utils/adapters/nextjs.d.ts +9 -0
- package/dist/utils/adapters/nextjs.js +64 -0
- package/dist/utils/adapters/nitro.d.ts +9 -0
- package/dist/utils/adapters/nitro.js +169 -0
- package/dist/utils/adapters/vite.d.ts +10 -0
- package/dist/utils/adapters/vite.js +33 -0
- package/dist/utils/asset-collection.d.ts +27 -6
- package/dist/utils/asset-collection.js +59 -30
- package/dist/utils/build-detection.d.ts +5 -11
- package/dist/utils/build-detection.js +74 -11
- package/dist/utils/build-lambda-zip.d.ts +16 -0
- package/dist/utils/build-lambda-zip.js +78 -0
- package/dist/utils/cache-bootstrap.d.ts +8 -0
- package/dist/utils/cache-bootstrap.js +18 -0
- package/dist/utils/config.js +1 -1
- package/dist/utils/deploy-adapter.d.ts +40 -0
- package/dist/utils/deploy-adapter.js +58 -0
- package/dist/utils/download-template.d.ts +9 -1
- package/dist/utils/download-template.js +24 -18
- package/dist/utils/env-management.d.ts +24 -7
- package/dist/utils/env-management.js +119 -64
- package/dist/utils/format-env-suffix.d.ts +12 -0
- package/dist/utils/format-env-suffix.js +13 -0
- package/dist/utils/formatter.js +23 -11
- package/dist/utils/fs-utils.d.ts +6 -0
- package/dist/utils/fs-utils.js +27 -0
- package/dist/utils/handle-upgrade.d.ts +9 -0
- package/dist/utils/handle-upgrade.js +41 -0
- package/dist/utils/lambda-config.d.ts +3 -1
- package/dist/utils/lambda-config.js +75 -78
- package/dist/utils/messages.d.ts +1 -2
- package/dist/utils/messages.js +39 -11
- package/dist/utils/package-manager.d.ts +24 -0
- package/dist/utils/package-manager.js +53 -0
- package/dist/utils/parse-template-spec.d.ts +12 -0
- package/dist/utils/parse-template-spec.js +62 -0
- package/dist/utils/payload-config-ast.d.ts +27 -6
- package/dist/utils/payload-config-ast.js +106 -58
- package/dist/utils/payload-config-finder.d.ts +2 -2
- package/dist/utils/payload-config-finder.js +48 -9
- package/dist/utils/payload-config-modifier.d.ts +1 -1
- package/dist/utils/payload-config-modifier.js +114 -66
- package/dist/utils/payload-package-check.d.ts +33 -2
- package/dist/utils/payload-package-check.js +129 -28
- package/dist/utils/project.d.ts +7 -2
- package/dist/utils/project.js +60 -32
- package/dist/utils/resolve-environment.d.ts +14 -0
- package/dist/utils/resolve-environment.js +31 -0
- package/dist/utils/s3-upload.d.ts +7 -2
- package/dist/utils/s3-upload.js +39 -6
- package/dist/utils/token-display.d.ts +5 -1
- package/dist/utils/token-display.js +49 -22
- package/dist/utils/typescript-validator.js +4 -6
- package/dist/utils/version-check.d.ts +3 -0
- package/dist/utils/version-check.js +38 -0
- package/package.json +44 -15
- package/dist/api/control-plane.d.ts.map +0 -1
- package/dist/api/control-plane.js.map +0 -1
- package/dist/api/figma-api.d.ts.map +0 -1
- package/dist/api/figma-api.js.map +0 -1
- package/dist/auth/browser.d.ts.map +0 -1
- package/dist/auth/browser.js.map +0 -1
- package/dist/auth/callback-server.d.ts.map +0 -1
- package/dist/auth/callback-server.js.map +0 -1
- package/dist/auth/crypto-utils.d.ts.map +0 -1
- package/dist/auth/crypto-utils.js.map +0 -1
- package/dist/auth/jwt-validator.d.ts.map +0 -1
- package/dist/auth/jwt-validator.js.map +0 -1
- package/dist/auth/oauth-flow.d.ts.map +0 -1
- package/dist/auth/oauth-flow.js.map +0 -1
- package/dist/auth/pkce.d.ts.map +0 -1
- package/dist/auth/pkce.js.map +0 -1
- package/dist/auth/project-token.d.ts.map +0 -1
- package/dist/auth/project-token.js.map +0 -1
- package/dist/auth/refresh.d.ts.map +0 -1
- package/dist/auth/refresh.js.map +0 -1
- package/dist/auth/token-store.d.ts.map +0 -1
- package/dist/auth/token-store.js.map +0 -1
- package/dist/auth/types.d.ts.map +0 -1
- package/dist/auth/types.js.map +0 -1
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/commands/deploy.d.ts.map +0 -1
- package/dist/commands/deploy.js.map +0 -1
- package/dist/commands/init.d.ts.map +0 -1
- package/dist/commands/init.js.map +0 -1
- package/dist/commands/list-tokens.d.ts.map +0 -1
- package/dist/commands/list-tokens.js.map +0 -1
- package/dist/commands/login.d.ts.map +0 -1
- package/dist/commands/login.js.map +0 -1
- package/dist/commands/logout.d.ts.map +0 -1
- package/dist/commands/logout.js.map +0 -1
- package/dist/config/oauth.d.ts.map +0 -1
- package/dist/config/oauth.js.map +0 -1
- package/dist/constants.d.ts.map +0 -1
- package/dist/constants.js.map +0 -1
- package/dist/exports/client.d.ts.map +0 -1
- package/dist/exports/client.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/oauth/components/LoginButton/index.d.ts.map +0 -1
- package/dist/oauth/components/LoginButton/index.js.map +0 -1
- package/dist/oauth/components/LogoutButton/index.d.ts.map +0 -1
- package/dist/oauth/components/LogoutButton/index.js.map +0 -1
- package/dist/oauth/defaults.d.ts.map +0 -1
- package/dist/oauth/defaults.js.map +0 -1
- package/dist/oauth/endpoints/getLoginEndpoint.d.ts.map +0 -1
- package/dist/oauth/endpoints/getLoginEndpoint.js.map +0 -1
- package/dist/oauth/endpoints/getLogoutEndpoint.d.ts.map +0 -1
- package/dist/oauth/endpoints/getLogoutEndpoint.js.map +0 -1
- package/dist/oauth/endpoints/getMetaEndpoint.d.ts.map +0 -1
- package/dist/oauth/endpoints/getMetaEndpoint.js.map +0 -1
- package/dist/oauth/endpoints/getRedirectToLoginEndpoint.d.ts.map +0 -1
- package/dist/oauth/endpoints/getRedirectToLoginEndpoint.js.map +0 -1
- package/dist/oauth/exports/client.d.ts.map +0 -1
- package/dist/oauth/exports/client.js.map +0 -1
- package/dist/oauth/hooks/afterLogout.d.ts.map +0 -1
- package/dist/oauth/hooks/afterLogout.js.map +0 -1
- package/dist/oauth/hooks/me.d.ts.map +0 -1
- package/dist/oauth/hooks/me.js.map +0 -1
- package/dist/oauth/hooks/refresh.d.ts.map +0 -1
- package/dist/oauth/hooks/refresh.js.map +0 -1
- package/dist/oauth/index.d.ts.map +0 -1
- package/dist/oauth/index.js.map +0 -1
- package/dist/oauth/strategy/index.d.ts.map +0 -1
- package/dist/oauth/strategy/index.js.map +0 -1
- package/dist/oauth/types.d.ts.map +0 -1
- package/dist/oauth/types.js.map +0 -1
- package/dist/oauth/utilities/clearCookie.d.ts.map +0 -1
- package/dist/oauth/utilities/clearCookie.js.map +0 -1
- package/dist/oauth/utilities/createCookieOptions.d.ts.map +0 -1
- package/dist/oauth/utilities/createCookieOptions.js.map +0 -1
- package/dist/oauth/utilities/createDebugLogger.d.ts.map +0 -1
- package/dist/oauth/utilities/createDebugLogger.js.map +0 -1
- package/dist/oauth/utilities/extractOrigin.d.ts.map +0 -1
- package/dist/oauth/utilities/extractOrigin.js.map +0 -1
- package/dist/oauth/utilities/getAdminCollectionSlug.d.ts.map +0 -1
- package/dist/oauth/utilities/getAdminCollectionSlug.js.map +0 -1
- package/dist/oauth/utilities/getAdminPath.d.ts +0 -8
- package/dist/oauth/utilities/getAdminPath.d.ts.map +0 -1
- package/dist/oauth/utilities/getAdminPath.js +0 -9
- package/dist/oauth/utilities/getAdminPath.js.map +0 -1
- package/dist/oauth/utilities/getAuthorizeURL.d.ts.map +0 -1
- package/dist/oauth/utilities/getAuthorizeURL.js.map +0 -1
- package/dist/oauth/utilities/getCookieExpiration.d.ts.map +0 -1
- package/dist/oauth/utilities/getCookieExpiration.js.map +0 -1
- package/dist/oauth/utilities/getSecondsFromTokenExp.d.ts.map +0 -1
- package/dist/oauth/utilities/getSecondsFromTokenExp.js.map +0 -1
- package/dist/oauth/utilities/getTokenExp.d.ts.map +0 -1
- package/dist/oauth/utilities/getTokenExp.js.map +0 -1
- package/dist/oauth/utilities/getUsernameField.d.ts.map +0 -1
- package/dist/oauth/utilities/getUsernameField.js.map +0 -1
- package/dist/oauth/utilities/hasUserTokenPropsChanged.d.ts.map +0 -1
- package/dist/oauth/utilities/hasUserTokenPropsChanged.js.map +0 -1
- package/dist/oauth/utilities/mergeHeaders.d.ts.map +0 -1
- package/dist/oauth/utilities/mergeHeaders.js.map +0 -1
- package/dist/oauth/utilities/refreshTokens.d.ts.map +0 -1
- package/dist/oauth/utilities/refreshTokens.js.map +0 -1
- package/dist/plugin/adapter.d.ts.map +0 -1
- package/dist/plugin/adapter.js.map +0 -1
- package/dist/plugin/build-config.d.ts.map +0 -1
- package/dist/plugin/build-config.js.map +0 -1
- package/dist/types/config.d.ts.map +0 -1
- package/dist/types/config.js.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/utils/asset-collection.d.ts.map +0 -1
- package/dist/utils/asset-collection.js.map +0 -1
- package/dist/utils/build-detection.d.ts.map +0 -1
- package/dist/utils/build-detection.js.map +0 -1
- package/dist/utils/config.d.ts.map +0 -1
- package/dist/utils/config.js.map +0 -1
- package/dist/utils/download-template.d.ts.map +0 -1
- package/dist/utils/download-template.js.map +0 -1
- package/dist/utils/env-management.d.ts.map +0 -1
- package/dist/utils/env-management.js.map +0 -1
- package/dist/utils/format.d.ts.map +0 -1
- package/dist/utils/format.js.map +0 -1
- package/dist/utils/formatter.d.ts.map +0 -1
- package/dist/utils/formatter.js.map +0 -1
- package/dist/utils/git.d.ts.map +0 -1
- package/dist/utils/git.js.map +0 -1
- package/dist/utils/is-debug.d.ts.map +0 -1
- package/dist/utils/is-debug.js.map +0 -1
- package/dist/utils/lambda-config.d.ts.map +0 -1
- package/dist/utils/lambda-config.js.map +0 -1
- package/dist/utils/log.d.ts.map +0 -1
- package/dist/utils/log.js.map +0 -1
- package/dist/utils/messages.d.ts.map +0 -1
- package/dist/utils/messages.js.map +0 -1
- package/dist/utils/package-manager.d.ts.map +0 -1
- package/dist/utils/package-manager.js.map +0 -1
- package/dist/utils/payload-config-ast.d.ts.map +0 -1
- package/dist/utils/payload-config-ast.js.map +0 -1
- package/dist/utils/payload-config-finder.d.ts.map +0 -1
- package/dist/utils/payload-config-finder.js.map +0 -1
- package/dist/utils/payload-config-modifier.d.ts.map +0 -1
- package/dist/utils/payload-config-modifier.js.map +0 -1
- package/dist/utils/payload-package-check.d.ts.map +0 -1
- package/dist/utils/payload-package-check.js.map +0 -1
- package/dist/utils/project.d.ts.map +0 -1
- package/dist/utils/project.js.map +0 -1
- package/dist/utils/s3-upload.d.ts.map +0 -1
- package/dist/utils/s3-upload.js.map +0 -1
- package/dist/utils/token-display.d.ts.map +0 -1
- package/dist/utils/token-display.js.map +0 -1
- package/dist/utils/typescript-validator.d.ts.map +0 -1
- package/dist/utils/typescript-validator.js.map +0 -1
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extracts all field paths from a where clause recursively
|
|
3
|
+
*/ function extractPathsFromWhere(where, paths = new Set()) {
|
|
4
|
+
if (!where || typeof where !== 'object') {
|
|
5
|
+
return paths;
|
|
6
|
+
}
|
|
7
|
+
// Handle 'and' operator
|
|
8
|
+
if ('and' in where && Array.isArray(where.and)) {
|
|
9
|
+
for (const clause of where.and){
|
|
10
|
+
extractPathsFromWhere(clause, paths);
|
|
11
|
+
}
|
|
12
|
+
return paths;
|
|
13
|
+
}
|
|
14
|
+
// Handle 'or' operator
|
|
15
|
+
if ('or' in where && Array.isArray(where.or)) {
|
|
16
|
+
for (const clause of where.or){
|
|
17
|
+
extractPathsFromWhere(clause, paths);
|
|
18
|
+
}
|
|
19
|
+
return paths;
|
|
20
|
+
}
|
|
21
|
+
// Handle regular conditions - keys are field paths
|
|
22
|
+
for(const key in where){
|
|
23
|
+
if (key === 'and' || key === 'or') {
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
// Add the path
|
|
27
|
+
paths.add(key.replace(/__/g, '.'));
|
|
28
|
+
// Check if the value is a nested where clause (for relationships)
|
|
29
|
+
const value = where[key];
|
|
30
|
+
if (value && typeof value === 'object' && !('equals' in value) && !('in' in value)) {
|
|
31
|
+
// Might be a nested where, recurse
|
|
32
|
+
extractPathsFromWhere(value, paths);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return paths;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Determines the type of a field based on its configuration.
|
|
39
|
+
* Returns PathTypeValue for fields that need special handling in Content API queries.
|
|
40
|
+
*/ function getFieldType(field) {
|
|
41
|
+
// Array field
|
|
42
|
+
if (field.type === 'array') {
|
|
43
|
+
return 'array';
|
|
44
|
+
}
|
|
45
|
+
// Blocks field (array of objects)
|
|
46
|
+
if (field.type === 'blocks') {
|
|
47
|
+
return 'array';
|
|
48
|
+
}
|
|
49
|
+
// Relationship field - always include for JOIN support
|
|
50
|
+
if (field.type === 'relationship') {
|
|
51
|
+
const { hasMany = false, relationTo: collection } = field;
|
|
52
|
+
return {
|
|
53
|
+
type: 'relationship',
|
|
54
|
+
collection,
|
|
55
|
+
hasMany
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
// Upload field - treated like relationship
|
|
59
|
+
if (field.type === 'upload') {
|
|
60
|
+
const { hasMany = false, relationTo: collection } = field;
|
|
61
|
+
return {
|
|
62
|
+
type: 'relationship',
|
|
63
|
+
collection,
|
|
64
|
+
hasMany
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
// Join field - virtual reverse lookup
|
|
68
|
+
if (field.type === 'join') {
|
|
69
|
+
const { collection, on } = field;
|
|
70
|
+
return {
|
|
71
|
+
type: 'join',
|
|
72
|
+
collection,
|
|
73
|
+
hasMany: true,
|
|
74
|
+
on
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
// Text field with hasMany (array of strings)
|
|
78
|
+
if (field.type === 'text' && 'hasMany' in field && field.hasMany) {
|
|
79
|
+
return 'array';
|
|
80
|
+
}
|
|
81
|
+
// Number field with hasMany (array of numbers)
|
|
82
|
+
if (field.type === 'number' && 'hasMany' in field && field.hasMany) {
|
|
83
|
+
return 'array';
|
|
84
|
+
}
|
|
85
|
+
// Select field with hasMany (array)
|
|
86
|
+
if (field.type === 'select' && 'hasMany' in field && field.hasMany) {
|
|
87
|
+
return 'array';
|
|
88
|
+
}
|
|
89
|
+
// Objects (group, collapsible, row, tabs) don't need traversal
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Finds a field in the collection schema by its path.
|
|
94
|
+
* Supports nested paths like "access.read.users".
|
|
95
|
+
* For localized array/blocks fields, locale key segments (e.g. "en") are skipped transparently,
|
|
96
|
+
* so "localizedBlocks.en.richText" resolves to the richText field inside localizedBlocks.
|
|
97
|
+
*/ function findFieldByPath(payload, collectionSlug, path) {
|
|
98
|
+
const collectionConfig = payload.config.collections.find((c)=>c.slug === collectionSlug);
|
|
99
|
+
if (!collectionConfig) {
|
|
100
|
+
return undefined;
|
|
101
|
+
}
|
|
102
|
+
const localeCodes = payload.config.localization ? payload.config.localization.localeCodes : [];
|
|
103
|
+
const pathSegments = path.split('.');
|
|
104
|
+
// Walk through the path segments to find the field
|
|
105
|
+
let currentFields = collectionConfig.fields;
|
|
106
|
+
let currentField = undefined;
|
|
107
|
+
for(let i = 0; i < pathSegments.length; i++){
|
|
108
|
+
const segment = pathSegments[i];
|
|
109
|
+
// If this segment is a locale key for the previously found localized array/blocks field,
|
|
110
|
+
// skip it transparently (the locale key is the wrapping object key, not a real field).
|
|
111
|
+
if (localeCodes.includes(segment) && currentField && 'localized' in currentField && currentField.localized && (currentField.type === 'blocks' || currentField.type === 'array')) {
|
|
112
|
+
if (i === pathSegments.length - 1) {
|
|
113
|
+
// Last segment is a locale key → return the localized field (represents locale-specific array)
|
|
114
|
+
return currentField;
|
|
115
|
+
}
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
// First try to find a direct match
|
|
119
|
+
currentField = currentFields.find((f)=>'name' in f && f.name === segment);
|
|
120
|
+
// If not found, check if any unnamed container fields (collapsible, row) contain it
|
|
121
|
+
if (!currentField) {
|
|
122
|
+
for (const field of currentFields){
|
|
123
|
+
if (!('name' in field) || !field.name) {
|
|
124
|
+
// This is an unnamed field, check its contents
|
|
125
|
+
if ('fields' in field && field.type === 'collapsible' || 'fields' in field && field.type === 'row' || 'fields' in field && field.type === 'group') {
|
|
126
|
+
currentField = field.fields.find((f)=>'name' in f && f.name === segment);
|
|
127
|
+
if (currentField) {
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
} else if ('tabs' in field && field.type === 'tabs') {
|
|
131
|
+
// Check all tabs
|
|
132
|
+
for (const tab of field.tabs){
|
|
133
|
+
// Named tab: the tab name itself is a path segment (acts like a group)
|
|
134
|
+
if ('name' in tab && tab.name === segment) {
|
|
135
|
+
currentField = {
|
|
136
|
+
name: tab.name,
|
|
137
|
+
type: 'group',
|
|
138
|
+
fields: tab.fields
|
|
139
|
+
};
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
// Unnamed tab: search its fields for the segment
|
|
143
|
+
const found = tab.fields.find((f)=>'name' in f && f.name === segment);
|
|
144
|
+
if (found) {
|
|
145
|
+
currentField = found;
|
|
146
|
+
break;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
if (currentField) {
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
if (!currentField) {
|
|
157
|
+
return undefined;
|
|
158
|
+
}
|
|
159
|
+
// If we're not at the end, get nested fields
|
|
160
|
+
if (i < pathSegments.length - 1) {
|
|
161
|
+
if (currentField.type === 'group' && 'fields' in currentField) {
|
|
162
|
+
currentFields = currentField.fields;
|
|
163
|
+
} else if (currentField.type === 'array' && 'fields' in currentField) {
|
|
164
|
+
currentFields = currentField.fields;
|
|
165
|
+
} else if (currentField.type === 'blocks' && 'blocks' in currentField) {
|
|
166
|
+
// Collect all fields from all block definitions to continue traversal
|
|
167
|
+
const allBlockFields = [];
|
|
168
|
+
for (const block of currentField.blocks){
|
|
169
|
+
allBlockFields.push(...block.fields);
|
|
170
|
+
}
|
|
171
|
+
currentFields = allBlockFields;
|
|
172
|
+
} else if ((currentField.type === 'relationship' || currentField.type === 'upload') && typeof currentField.relationTo === 'string') {
|
|
173
|
+
// Traverse into the related collection's fields
|
|
174
|
+
const { relationTo } = currentField;
|
|
175
|
+
const relatedConfig = payload.config.collections.find((c)=>c.slug === relationTo);
|
|
176
|
+
if (relatedConfig) {
|
|
177
|
+
currentFields = relatedConfig.fields;
|
|
178
|
+
} else {
|
|
179
|
+
return undefined;
|
|
180
|
+
}
|
|
181
|
+
} else {
|
|
182
|
+
// Field doesn't have nested fields, can't continue
|
|
183
|
+
return undefined;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return currentField;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Builds pathTypes metadata for Content API request.
|
|
191
|
+
* Returns a record of paths with their types for proper query generation.
|
|
192
|
+
*
|
|
193
|
+
* Includes:
|
|
194
|
+
* - Array fields (type: "array")
|
|
195
|
+
* - Relationship fields (type: { type: "relationship", collection, hasMany })
|
|
196
|
+
* - Join fields (type: { type: "join", collection, hasMany, on })
|
|
197
|
+
*
|
|
198
|
+
* Localized array/blocks fields (stored as locale maps) are handled specially:
|
|
199
|
+
* - The localized field itself is NOT marked as 'array' (it's a locale map object)
|
|
200
|
+
* - The locale-specific path (e.g. "localizedBlocks.en") IS marked as 'array'
|
|
201
|
+
*/ export function buildPathTypes(payload, collectionSlug, where) {
|
|
202
|
+
if (!where) {
|
|
203
|
+
return {};
|
|
204
|
+
}
|
|
205
|
+
const localeCodes = payload.config.localization ? payload.config.localization.localeCodes : [];
|
|
206
|
+
const pathTypes = {};
|
|
207
|
+
const paths = extractPathsFromWhere(where);
|
|
208
|
+
for (const path of paths){
|
|
209
|
+
// For each path, we need to check all segments to see if any intermediate ones are arrays/relationships
|
|
210
|
+
const segments = path.split('.');
|
|
211
|
+
for(let i = 0; i < segments.length; i++){
|
|
212
|
+
const partialPath = segments.slice(0, i + 1).join('.');
|
|
213
|
+
// Skip if we already have this path
|
|
214
|
+
if (partialPath in pathTypes) {
|
|
215
|
+
continue;
|
|
216
|
+
}
|
|
217
|
+
// If the current segment is a locale code and the parent field is a localized array/blocks,
|
|
218
|
+
// mark this locale-specific path as 'array' (the per-locale content is the actual array).
|
|
219
|
+
if (i > 0 && localeCodes.includes(segments[i])) {
|
|
220
|
+
const parentPath = segments.slice(0, i).join('.');
|
|
221
|
+
const parentField = findFieldByPath(payload, collectionSlug, parentPath);
|
|
222
|
+
if (parentField && 'localized' in parentField && parentField.localized && (parentField.type === 'blocks' || parentField.type === 'array')) {
|
|
223
|
+
pathTypes[partialPath] = 'array';
|
|
224
|
+
continue;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
const field = findFieldByPath(payload, collectionSlug, partialPath);
|
|
228
|
+
if (field) {
|
|
229
|
+
// Localized array/blocks fields are stored as locale maps (not arrays).
|
|
230
|
+
// Skip them here — the locale-specific path (e.g. "localizedBlocks.en") is marked above.
|
|
231
|
+
if ('localized' in field && field.localized && (field.type === 'blocks' || field.type === 'array')) {
|
|
232
|
+
continue;
|
|
233
|
+
}
|
|
234
|
+
const fieldType = getFieldType(field);
|
|
235
|
+
if (fieldType !== null) {
|
|
236
|
+
pathTypes[partialPath] = fieldType;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
return pathTypes;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
//# sourceMappingURL=buildPathTypes.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Payload } from 'payload';
|
|
2
|
+
import type { components } from '../../generated/content-api-types.js';
|
|
3
|
+
type UniquePath = components['schemas']['UniquePath'];
|
|
4
|
+
/**
|
|
5
|
+
* Builds a UniquePath[] from the collection's field config by collecting
|
|
6
|
+
* all fields with `unique: true` that have a non-null value in the data.
|
|
7
|
+
*
|
|
8
|
+
* Fields with null/undefined values are excluded to match sparse unique index
|
|
9
|
+
* behavior (multiple documents can have null for a unique field).
|
|
10
|
+
*/
|
|
11
|
+
export declare function buildUniquePaths(payload: Payload, collectionSlug: string, data: Record<string, unknown>): UniquePath[];
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=buildUniquePaths.d.ts.map
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds a UniquePath[] from the collection's field config by collecting
|
|
3
|
+
* all fields with `unique: true` that have a non-null value in the data.
|
|
4
|
+
*
|
|
5
|
+
* Fields with null/undefined values are excluded to match sparse unique index
|
|
6
|
+
* behavior (multiple documents can have null for a unique field).
|
|
7
|
+
*/ export function buildUniquePaths(payload, collectionSlug, data) {
|
|
8
|
+
const isGlobal = collectionSlug.startsWith('_global-');
|
|
9
|
+
const actualSlug = isGlobal ? collectionSlug.substring(8) : collectionSlug;
|
|
10
|
+
const config = isGlobal ? payload.config.globals?.find((g)=>g.slug === actualSlug) : payload.config.collections.find((c)=>c.slug === actualSlug);
|
|
11
|
+
if (!config?.fields) {
|
|
12
|
+
return [];
|
|
13
|
+
}
|
|
14
|
+
const unique = [];
|
|
15
|
+
collectUniqueFields(config.fields, '', data, unique);
|
|
16
|
+
return unique;
|
|
17
|
+
}
|
|
18
|
+
function getValueAtPath(data, path) {
|
|
19
|
+
const segments = path.split('.');
|
|
20
|
+
let current = data;
|
|
21
|
+
for (const segment of segments){
|
|
22
|
+
if (current == null || typeof current !== 'object') {
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
current = current[segment];
|
|
26
|
+
}
|
|
27
|
+
return current;
|
|
28
|
+
}
|
|
29
|
+
function collectUniqueFields(fields, prefix, data, result) {
|
|
30
|
+
for (const field of fields){
|
|
31
|
+
if (field.type === 'row' || field.type === 'collapsible') {
|
|
32
|
+
collectUniqueFields(field.fields, prefix, data, result);
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
if (field.type === 'tabs') {
|
|
36
|
+
for (const tab of field.tabs){
|
|
37
|
+
const tabPrefix = 'name' in tab && tab.name ? `${prefix}${tab.name}.` : prefix;
|
|
38
|
+
collectUniqueFields(tab.fields, tabPrefix, data, result);
|
|
39
|
+
}
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
if (!('name' in field) || !field.name) {
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
const path = prefix + field.name;
|
|
46
|
+
if ('unique' in field && field.unique) {
|
|
47
|
+
const value = getValueAtPath(data, path);
|
|
48
|
+
if (value != null) {
|
|
49
|
+
result.push({
|
|
50
|
+
paths: [
|
|
51
|
+
path
|
|
52
|
+
]
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
if (field.type === 'group' && 'fields' in field) {
|
|
57
|
+
collectUniqueFields(field.fields, `${path}.`, data, result);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
//# sourceMappingURL=buildUniquePaths.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Payload, Where } from 'payload';
|
|
2
|
+
/**
|
|
3
|
+
* Normalizes a Where clause by inserting locale keys into paths that traverse
|
|
4
|
+
* localized array/blocks fields without an explicit locale.
|
|
5
|
+
*
|
|
6
|
+
* Only runs when a locale is provided and the collection has localized array/blocks fields.
|
|
7
|
+
* Returns the original where clause if no transformation is needed.
|
|
8
|
+
*/
|
|
9
|
+
export declare function normalizeLocaleInWhere(where: undefined | Where, payload: Payload, collectionSlug: string, locale: string | undefined): undefined | Where;
|
|
10
|
+
//# sourceMappingURL=normalizeLocaleInWhere.d.ts.map
|
|
@@ -0,0 +1,102 @@
|
|
|
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
|
+
}
|
|
101
|
+
|
|
102
|
+
//# sourceMappingURL=normalizeLocaleInWhere.js.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Where } from 'payload';
|
|
2
|
+
import type { components } from '../generated/content-api-types.js';
|
|
3
|
+
type WhereClause = components['schemas']['WhereClause'];
|
|
4
|
+
type ConvertOptions = {
|
|
5
|
+
/** Internal flag to track if we're inside a logical operator (and/or) */
|
|
6
|
+
insideLogicalOperator?: boolean;
|
|
7
|
+
/** If true, transform 'parent' field to 'documentId' (used for version queries) */
|
|
8
|
+
parentToDocumentId?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* If true, strip 'version.' prefix from field paths (used for version queries).
|
|
11
|
+
*
|
|
12
|
+
* Payload queries version content with paths like 'version._status.en', but Content API
|
|
13
|
+
* stores version data directly in the 'data' column (not nested under 'version').
|
|
14
|
+
* The 'version' wrapper is only added in API responses for client compatibility.
|
|
15
|
+
*/
|
|
16
|
+
stripVersionPrefix?: boolean;
|
|
17
|
+
};
|
|
18
|
+
export declare function convertPayloadWhereToContentAPI(where: undefined | Where, options?: ConvertOptions): WhereClause;
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=where.d.ts.map
|
|
@@ -0,0 +1,108 @@
|
|
|
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
|
+
// TODO: fix this in content api
|
|
34
|
+
// WORKAROUND: Payload uses 'parent' for version queries, but Content API expects 'documentId'
|
|
35
|
+
let fieldPath = key.replace(/__/g, '.');
|
|
36
|
+
if (options.parentToDocumentId && key === 'parent') {
|
|
37
|
+
fieldPath = 'documentId';
|
|
38
|
+
}
|
|
39
|
+
// Strip 'version.' prefix from field paths for version queries
|
|
40
|
+
// Payload uses paths like 'version._status.en' but Content API stores version data
|
|
41
|
+
// directly in the 'data' column, not nested under 'version'
|
|
42
|
+
if (options.stripVersionPrefix && fieldPath.startsWith('version.')) {
|
|
43
|
+
fieldPath = fieldPath.slice('version.'.length);
|
|
44
|
+
}
|
|
45
|
+
// Convert field conditions: { fieldName: { operator: value } }
|
|
46
|
+
// to: { path: fieldName, operator, value }
|
|
47
|
+
// Handle Payload's shorthand: { fieldName: value } → { fieldName: { equals: value } }
|
|
48
|
+
// If value is a primitive (string, number, boolean, null) or not a plain object,
|
|
49
|
+
// treat it as an implicit 'equals' operator
|
|
50
|
+
const isPrimitive = value === null || typeof value !== 'object' || Array.isArray(value);
|
|
51
|
+
if (isPrimitive) {
|
|
52
|
+
// Shorthand format: { id: "some-value" } means { id: { equals: "some-value" } }
|
|
53
|
+
conditions.push({
|
|
54
|
+
operator: 'equals',
|
|
55
|
+
path: fieldPath,
|
|
56
|
+
value: fieldPath === 'id' && typeof value === 'number' ? String(value) : value
|
|
57
|
+
});
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
const operators = value;
|
|
61
|
+
// Skip empty operator objects { fieldName: {} }
|
|
62
|
+
if (Object.keys(operators).length === 0) {
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
for (const [op, operatorValue] of Object.entries(operators)){
|
|
66
|
+
// Skip operators with undefined values (e.g., { equals: undefined })
|
|
67
|
+
// This can happen when Payload sends incomplete where clauses
|
|
68
|
+
if (operatorValue === undefined) {
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
let finalValue = operatorValue;
|
|
72
|
+
// Convert string booleans to actual booleans for exists operator
|
|
73
|
+
// REST API sends "true"/"false" as strings, but Content API requires boolean
|
|
74
|
+
if (op === 'exists' && typeof operatorValue === 'string') {
|
|
75
|
+
finalValue = operatorValue === 'true';
|
|
76
|
+
}
|
|
77
|
+
// REST API sends "null" as a string; convert to actual null
|
|
78
|
+
if (finalValue === 'null') {
|
|
79
|
+
finalValue = null;
|
|
80
|
+
}
|
|
81
|
+
// Content API stores all document IDs as strings.
|
|
82
|
+
// Payload sends numeric values for collections with custom numeric ID fields,
|
|
83
|
+
// so we must stringify to match.
|
|
84
|
+
if (fieldPath === 'id' && typeof finalValue === 'number') {
|
|
85
|
+
finalValue = String(finalValue);
|
|
86
|
+
}
|
|
87
|
+
conditions.push({
|
|
88
|
+
operator: op,
|
|
89
|
+
path: fieldPath,
|
|
90
|
+
value: finalValue
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (conditions.length === 0) {
|
|
96
|
+
return {
|
|
97
|
+
and: []
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
if (options.insideLogicalOperator && conditions.length === 1) {
|
|
101
|
+
return conditions[0];
|
|
102
|
+
}
|
|
103
|
+
return {
|
|
104
|
+
and: conditions
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
//# sourceMappingURL=where.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
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;
|
|
11
|
+
//# sourceMappingURL=schedule-extract-plugin.d.ts.map
|
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
}
|
|
33
|
+
|
|
34
|
+
//# sourceMappingURL=schedule-extract-plugin.js.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import crypto from 'crypto';
|
|
2
|
+
import { configToJSONSchema } from 'payload';
|
|
3
|
+
export const schema = {
|
|
4
|
+
handler: (req)=>{
|
|
5
|
+
if (!req.user) {
|
|
6
|
+
return Response.json({
|
|
7
|
+
error: 'Unauthorized'
|
|
8
|
+
}, {
|
|
9
|
+
status: 401
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
const format = req.query?.format;
|
|
13
|
+
const jsonSchema = configToJSONSchema(req.payload.config);
|
|
14
|
+
const hash = crypto.createHash('sha256').update(JSON.stringify(jsonSchema)).digest('hex');
|
|
15
|
+
if (format === 'hash') {
|
|
16
|
+
return Response.json({
|
|
17
|
+
hash
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return Response.json({
|
|
21
|
+
hash,
|
|
22
|
+
schema: jsonSchema
|
|
23
|
+
});
|
|
24
|
+
},
|
|
25
|
+
method: 'get',
|
|
26
|
+
path: '/figma/schema'
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=schema.js.map
|
package/dist/exports/client.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
export { FigmaAvatar } from '../oauth/components/FigmaAvatar/index.js';
|
|
2
|
+
export { FigmaAvatarCell } from '../oauth/components/FigmaAvatarCell/index.js';
|
|
1
3
|
export { DefaultLoginButton } from '../oauth/components/LoginButton/index.js';
|
|
2
4
|
export { LogoutButton } from '../oauth/components/LogoutButton/index.js';
|
|
5
|
+
export { ContentApiClientUploadHandler } from '../storage-content-api/client-uploads/ClientUploadHandler.js';
|
|
3
6
|
//# sourceMappingURL=client.d.ts.map
|