@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
|
@@ -1,26 +1,319 @@
|
|
|
1
|
+
import { cloudStoragePlugin } from '@payloadcms/plugin-cloud-storage';
|
|
2
|
+
import { initClientUploads } from '@payloadcms/plugin-cloud-storage/utilities';
|
|
1
3
|
import { lexicalEditor } from '@payloadcms/richtext-lexical';
|
|
2
4
|
import { buildConfig as payloadBuildConfig } from 'payload';
|
|
5
|
+
import { getBootstrapInfo } from '../api/control-plane.js';
|
|
6
|
+
import { getValidCredential } from '../auth/oauth-flow.js';
|
|
7
|
+
import { getTokenStore } from '../auth/token-store.js';
|
|
8
|
+
import { getEnvConfig } from '../constants.js';
|
|
9
|
+
import { contentAPIAdapter } from '../db-content-api/index.js';
|
|
10
|
+
import { scheduleExtractPlugin } from '../deploy/schedule-extract-plugin.js';
|
|
11
|
+
import { health } from '../endpoints/health.js';
|
|
12
|
+
import { schema } from '../endpoints/schema.js';
|
|
3
13
|
import { oAuth2Plugin } from '../oauth/index.js';
|
|
4
|
-
import {
|
|
14
|
+
import { createStorageClient } from '../storage-content-api/client.js';
|
|
15
|
+
import { getGenerateSignedURLHandler } from '../storage-content-api/client-uploads/generateSignedURL.js';
|
|
16
|
+
import { contentApiStorageAdapter } from '../storage-content-api/index.js';
|
|
17
|
+
import { cacheAllEnvironments } from '../utils/cache-bootstrap.js';
|
|
18
|
+
import { getEnvVarSync } from '../utils/env-management.js';
|
|
19
|
+
import * as log from '../utils/log.js';
|
|
20
|
+
import { logMissingCliAuth } from './auth-preflight.js';
|
|
21
|
+
import { logMissingContentSystemId } from './bootstrap-preflight.js';
|
|
22
|
+
import { getDevCookieNames } from './dev-cookie-names.js';
|
|
5
23
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* - Default lexicalEditor (if no custom editor specified)
|
|
24
|
+
* Worker-trusted marker injected by Figma's sites-worker after it validates the
|
|
25
|
+
* X-Figma-Job-Queues-Auth-Bypass secret on a Payload jobs endpoint. The default
|
|
26
|
+
* `jobs.access.run` below honors this marker so Sinatra (async-job-workflow)
|
|
27
|
+
* can drive job runs without the bypass secret ever reaching tenant code.
|
|
11
28
|
*
|
|
12
|
-
*
|
|
13
|
-
|
|
14
|
-
|
|
29
|
+
* KEEP_IN_SYNC(cloudflare/wrangler/sites-worker/src/auth.ts): FIGMA_INTERNAL_FORWARDED_HAS_AUTH_BYPASS_HEADER
|
|
30
|
+
*/ export const FIGMA_INTERNAL_FORWARDED_HAS_AUTH_BYPASS_HEADER = 'figma-internal-forwarded-has-auth-bypass';
|
|
31
|
+
/**
|
|
32
|
+
* Fields added to users collection for Figma profile info
|
|
33
|
+
*/ const figmaUserFields = [
|
|
34
|
+
{
|
|
35
|
+
name: 'figmaHandle',
|
|
36
|
+
type: 'text',
|
|
37
|
+
admin: {
|
|
38
|
+
readOnly: true
|
|
39
|
+
},
|
|
40
|
+
label: 'Name'
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: 'figmaImageUrl',
|
|
44
|
+
type: 'text',
|
|
45
|
+
admin: {
|
|
46
|
+
components: {
|
|
47
|
+
Cell: '@payloadcms/figma/client#FigmaAvatarCell'
|
|
48
|
+
},
|
|
49
|
+
disableBulkEdit: true,
|
|
50
|
+
hidden: true,
|
|
51
|
+
readOnly: true
|
|
52
|
+
},
|
|
53
|
+
label: 'Profile Picture'
|
|
54
|
+
}
|
|
55
|
+
];
|
|
56
|
+
function missingOAuthCredential(name) {
|
|
57
|
+
log.warning(`${name} could not be resolved. OAuth login will not work until this is configured. ` + 'Run `npx @payloadcms/figma init` to set up your project.');
|
|
58
|
+
return '';
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Fetch bootstrap data from the API and cache all environments locally.
|
|
62
|
+
* Returns the requested environment's data, or a typed failure reason.
|
|
63
|
+
*/ async function resolveAndCacheBootstrap(store, projectId, environmentName) {
|
|
64
|
+
let credential;
|
|
65
|
+
try {
|
|
66
|
+
credential = await getValidCredential(store);
|
|
67
|
+
} catch (error) {
|
|
68
|
+
return {
|
|
69
|
+
ok: false,
|
|
70
|
+
reason: {
|
|
71
|
+
kind: 'network',
|
|
72
|
+
message: messageOf(error)
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
if (!credential) {
|
|
77
|
+
return {
|
|
78
|
+
ok: false,
|
|
79
|
+
reason: {
|
|
80
|
+
kind: 'unauthenticated'
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
try {
|
|
85
|
+
const bootstrapInfo = await getBootstrapInfo(credential, projectId);
|
|
86
|
+
cacheAllEnvironments(store, projectId, bootstrapInfo);
|
|
87
|
+
} catch (error) {
|
|
88
|
+
return {
|
|
89
|
+
ok: false,
|
|
90
|
+
reason: {
|
|
91
|
+
kind: 'network',
|
|
92
|
+
message: messageOf(error)
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
const data = store.getBootstrapData(projectId, environmentName);
|
|
97
|
+
if (!data) {
|
|
98
|
+
return {
|
|
99
|
+
ok: false,
|
|
100
|
+
reason: {
|
|
101
|
+
environmentName,
|
|
102
|
+
kind: 'environment-not-found',
|
|
103
|
+
projectId
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
return {
|
|
108
|
+
data,
|
|
109
|
+
ok: true
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
function messageOf(error) {
|
|
113
|
+
return error instanceof Error ? error.message : 'Unknown error';
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Creates storage configuration for upload collections
|
|
117
|
+
*/ function createStorageConfig(url, contentSystemId) {
|
|
118
|
+
const storageConfig = process.env.FIGMA_CONTENT_API_ACCESS_KEY ? {
|
|
119
|
+
baseUrl: url,
|
|
120
|
+
contentApiKey: process.env.FIGMA_CONTENT_API_ACCESS_KEY
|
|
121
|
+
} : process.env.FIGMA_DEV_JWT === 'true' ? {
|
|
122
|
+
auth: {
|
|
123
|
+
mode: 'devJwt'
|
|
124
|
+
},
|
|
125
|
+
baseUrl: url,
|
|
126
|
+
contentSystemId
|
|
127
|
+
} : {
|
|
128
|
+
auth: {
|
|
129
|
+
mode: 'tokenStore',
|
|
130
|
+
tokenStore: getTokenStore()
|
|
131
|
+
},
|
|
132
|
+
baseUrl: url,
|
|
133
|
+
contentSystemId
|
|
134
|
+
};
|
|
135
|
+
const adapter = contentApiStorageAdapter(storageConfig);
|
|
136
|
+
const storageClient = createStorageClient(storageConfig);
|
|
137
|
+
return {
|
|
138
|
+
adapter,
|
|
139
|
+
storageClient
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Plugin that applies cloud storage configuration to all upload-enabled collections.
|
|
144
|
+
* Runs at the end of the plugin chain so it sees collections added by user plugins too.
|
|
145
|
+
*/ function createStoragePlugin(url, contentSystemId) {
|
|
146
|
+
return (incomingConfig)=>{
|
|
147
|
+
const uploadCollections = (incomingConfig.collections || []).filter((c)=>c.upload);
|
|
148
|
+
if (uploadCollections.length === 0) {
|
|
149
|
+
return incomingConfig;
|
|
150
|
+
}
|
|
151
|
+
const { adapter, storageClient } = createStorageConfig(url, contentSystemId);
|
|
152
|
+
const collectionsMap = uploadCollections.reduce((acc, c)=>{
|
|
153
|
+
acc[c.slug] = {
|
|
154
|
+
adapter,
|
|
155
|
+
disableLocalStorage: true
|
|
156
|
+
};
|
|
157
|
+
return acc;
|
|
158
|
+
}, {});
|
|
159
|
+
initClientUploads({
|
|
160
|
+
clientHandler: '@payloadcms/figma/client#ContentApiClientUploadHandler',
|
|
161
|
+
collections: collectionsMap,
|
|
162
|
+
config: incomingConfig,
|
|
163
|
+
enabled: true,
|
|
164
|
+
serverHandler: getGenerateSignedURLHandler({
|
|
165
|
+
client: storageClient
|
|
166
|
+
}),
|
|
167
|
+
serverHandlerPath: '/content-api-storage-signed-url'
|
|
168
|
+
});
|
|
169
|
+
const storagePlugin = cloudStoragePlugin({
|
|
170
|
+
collections: collectionsMap
|
|
171
|
+
});
|
|
172
|
+
return storagePlugin(incomingConfig);
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
export async function buildFigmaConfig(config) {
|
|
176
|
+
const envConfig = getEnvConfig();
|
|
177
|
+
// Resolve contentSystemId: config first, env var, then local store fallback (dev)
|
|
178
|
+
let { contentSystemId } = config.figma;
|
|
179
|
+
contentSystemId ??= process.env.FIGMA_CONTENT_API_CONTENT_SYSTEM_ID;
|
|
180
|
+
let bootstrapData = null;
|
|
181
|
+
let bootstrapReason = null;
|
|
182
|
+
// Local dev: resolve from project ID + bootstrap cache
|
|
183
|
+
// Use getEnvVarSync fallback because Next.js evaluates config before dotenv populates process.env
|
|
184
|
+
if (!contentSystemId) {
|
|
185
|
+
const projectId = process.env.FIGMA_PROJECT_ID ?? getEnvVarSync(process.cwd(), 'FIGMA_PROJECT_ID');
|
|
186
|
+
const environmentName = process.env.FIGMA_ENVIRONMENT_NAME ?? getEnvVarSync(process.cwd(), 'FIGMA_ENVIRONMENT_NAME');
|
|
187
|
+
if (!projectId || !environmentName) {
|
|
188
|
+
bootstrapReason = {
|
|
189
|
+
kind: 'no-config'
|
|
190
|
+
};
|
|
191
|
+
} else {
|
|
192
|
+
const store = getTokenStore();
|
|
193
|
+
bootstrapData = store.getBootstrapData(projectId, environmentName);
|
|
194
|
+
// Runtime fallback: fetch from API if not cached (e.g. environment switch without re-init)
|
|
195
|
+
if (!bootstrapData) {
|
|
196
|
+
const resolution = await resolveAndCacheBootstrap(store, projectId, environmentName);
|
|
197
|
+
if (resolution.ok) {
|
|
198
|
+
bootstrapData = resolution.data;
|
|
199
|
+
} else {
|
|
200
|
+
bootstrapReason = resolution.reason;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
if (bootstrapData) {
|
|
204
|
+
contentSystemId = bootstrapData.contentSystemId;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
if (!contentSystemId) {
|
|
209
|
+
logMissingContentSystemId(bootstrapReason ?? {
|
|
210
|
+
kind: 'no-config'
|
|
211
|
+
});
|
|
212
|
+
throw new Error('Content System ID could not be resolved. ' + 'Run `npx @payloadcms/figma init` to set up your project.');
|
|
213
|
+
}
|
|
214
|
+
const url = process.env.FIGMA_CONTENT_API_URL || envConfig.contentApiUrl;
|
|
215
|
+
const isProduction = process.env.NODE_ENV === 'production';
|
|
216
|
+
// The deployed Lambda runs all queued jobs; locally there is no runner, so the db adapter logs
|
|
217
|
+
// a heads-up whenever a job is queued. Deployed environments set DISABLE_LOCAL_JOB_QUEUE_NOTIFICATIONS=true
|
|
218
|
+
// (injected by the control plane); end-users can also set it locally to silence the notice.
|
|
219
|
+
const notifyLocalJobQueue = process.env.DISABLE_LOCAL_JOB_QUEUE_NOTIFICATIONS !== 'true';
|
|
220
|
+
const usesTokenStoreAuth = !process.env.FIGMA_CONTENT_API_ACCESS_KEY && process.env.FIGMA_DEV_JWT !== 'true';
|
|
221
|
+
if (usesTokenStoreAuth) {
|
|
222
|
+
logMissingCliAuth(getTokenStore());
|
|
223
|
+
}
|
|
224
|
+
// Determine database adapter based on environment
|
|
225
|
+
let db;
|
|
226
|
+
if (config.figma.useContentSystem === false) {
|
|
227
|
+
db = config.db;
|
|
228
|
+
} else if (process.env.FIGMA_CONTENT_API_ACCESS_KEY) {
|
|
229
|
+
db = contentAPIAdapter({
|
|
230
|
+
auth: {
|
|
231
|
+
apiKey: process.env.FIGMA_CONTENT_API_ACCESS_KEY,
|
|
232
|
+
mode: 'apiKey'
|
|
233
|
+
},
|
|
234
|
+
contentSystemId,
|
|
235
|
+
environmentName: process.env.FIGMA_ENVIRONMENT_NAME,
|
|
236
|
+
notifyLocalJobQueue,
|
|
237
|
+
url
|
|
238
|
+
});
|
|
239
|
+
} else if (process.env.FIGMA_DEV_JWT === 'true') {
|
|
240
|
+
db = contentAPIAdapter({
|
|
241
|
+
auth: {
|
|
242
|
+
mode: 'devJwt'
|
|
243
|
+
},
|
|
244
|
+
contentSystemId,
|
|
245
|
+
environmentName: process.env.FIGMA_ENVIRONMENT_NAME,
|
|
246
|
+
notifyLocalJobQueue,
|
|
247
|
+
url
|
|
248
|
+
});
|
|
249
|
+
} else {
|
|
250
|
+
db = contentAPIAdapter({
|
|
251
|
+
auth: {
|
|
252
|
+
mode: 'tokenStore',
|
|
253
|
+
tokenStore: getTokenStore()
|
|
254
|
+
},
|
|
255
|
+
contentSystemId,
|
|
256
|
+
environmentName: process.env.FIGMA_ENVIRONMENT_NAME,
|
|
257
|
+
notifyLocalJobQueue,
|
|
258
|
+
url
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
const userJobsAccessRun = config.jobs?.access?.run;
|
|
15
262
|
// Build complete config with Figma platform defaults
|
|
16
263
|
const configWithFigmaDefaults = {
|
|
17
264
|
...config,
|
|
18
|
-
|
|
265
|
+
admin: {
|
|
266
|
+
// Auto-refresh tokens before expiry to prevent unexpected logouts.
|
|
267
|
+
autoRefresh: true,
|
|
268
|
+
avatar: {
|
|
269
|
+
Component: '@payloadcms/figma/client#FigmaAvatar'
|
|
270
|
+
},
|
|
271
|
+
...config.admin
|
|
272
|
+
},
|
|
273
|
+
custom: {
|
|
274
|
+
figma: {
|
|
275
|
+
...config.figma,
|
|
276
|
+
contentSystemId
|
|
277
|
+
}
|
|
278
|
+
},
|
|
279
|
+
db,
|
|
19
280
|
editor: config.editor ?? lexicalEditor(),
|
|
281
|
+
endpoints: [
|
|
282
|
+
...config.endpoints ?? [],
|
|
283
|
+
health,
|
|
284
|
+
schema
|
|
285
|
+
],
|
|
286
|
+
// Gate /api/payload-jobs/run and /api/payload-jobs/handle-schedules. Honor the
|
|
287
|
+
// sites-worker trust marker so Figma infra job runs never break, defer to the
|
|
288
|
+
// tenant's jobs.access.run if they set one, otherwise fall back to Payload's
|
|
289
|
+
// "logged-in user" default so the admin "Run jobs" UI keeps working.
|
|
290
|
+
jobs: {
|
|
291
|
+
...config.jobs ?? {},
|
|
292
|
+
access: {
|
|
293
|
+
...config.jobs?.access ?? {},
|
|
294
|
+
run: (args)=>{
|
|
295
|
+
if (args.req.headers.get(FIGMA_INTERNAL_FORWARDED_HAS_AUTH_BYPASS_HEADER) === '1') {
|
|
296
|
+
return true;
|
|
297
|
+
}
|
|
298
|
+
if (userJobsAccessRun) {
|
|
299
|
+
return userJobsAccessRun(args);
|
|
300
|
+
}
|
|
301
|
+
return !!args.req.user;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
},
|
|
305
|
+
...isProduction && !config.logger ? {
|
|
306
|
+
logger: {
|
|
307
|
+
options: {}
|
|
308
|
+
}
|
|
309
|
+
} : {},
|
|
20
310
|
secret: 'MY_SECRET',
|
|
21
311
|
// Add oauth to plugins if not already present
|
|
22
312
|
plugins: [
|
|
23
313
|
...config.plugins ?? [],
|
|
314
|
+
...config.figma.storage !== false ? [
|
|
315
|
+
createStoragePlugin(url, contentSystemId)
|
|
316
|
+
] : [],
|
|
24
317
|
oAuth2Plugin({
|
|
25
318
|
collections: [
|
|
26
319
|
{
|
|
@@ -30,9 +323,9 @@ import { figmaContentSystem } from './adapter.js';
|
|
|
30
323
|
response_mode: 'query',
|
|
31
324
|
response_type: 'code'
|
|
32
325
|
},
|
|
33
|
-
clientID: process.env.FIGMA_OAUTH_CLIENT_ID,
|
|
34
|
-
clientSecret: process.env.FIGMA_OAUTH_CLIENT_SECRET,
|
|
35
|
-
identityMetadata:
|
|
326
|
+
clientID: process.env.FIGMA_OAUTH_CLIENT_ID ?? bootstrapData?.oauthClientId ?? missingOAuthCredential('FIGMA_OAUTH_CLIENT_ID'),
|
|
327
|
+
clientSecret: process.env.FIGMA_OAUTH_CLIENT_SECRET ?? bootstrapData?.oauthClientSecret,
|
|
328
|
+
identityMetadata: envConfig.identityMetadata,
|
|
36
329
|
scope: [
|
|
37
330
|
'current_user:read'
|
|
38
331
|
],
|
|
@@ -40,12 +333,29 @@ import { figmaContentSystem } from './adapter.js';
|
|
|
40
333
|
usernameField: 'email'
|
|
41
334
|
}
|
|
42
335
|
],
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
})
|
|
336
|
+
...isProduction ? {} : getDevCookieNames(contentSystemId),
|
|
337
|
+
debug: !!process.env.DEBUG,
|
|
338
|
+
disabled: false
|
|
339
|
+
}),
|
|
340
|
+
scheduleExtractPlugin()
|
|
47
341
|
]
|
|
48
342
|
};
|
|
343
|
+
// Inject figma fields into users collection
|
|
344
|
+
const collections = configWithFigmaDefaults.collections?.map((col)=>{
|
|
345
|
+
if (col.slug === 'users') {
|
|
346
|
+
return {
|
|
347
|
+
...col,
|
|
348
|
+
fields: [
|
|
349
|
+
...col.fields || [],
|
|
350
|
+
...figmaUserFields
|
|
351
|
+
]
|
|
352
|
+
};
|
|
353
|
+
}
|
|
354
|
+
return col;
|
|
355
|
+
});
|
|
356
|
+
if (collections) {
|
|
357
|
+
configWithFigmaDefaults.collections = collections;
|
|
358
|
+
}
|
|
49
359
|
// Delegate to Payload's buildConfig
|
|
50
360
|
return await payloadBuildConfig(configWithFigmaDefaults);
|
|
51
361
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Namespace OAuth cookies per-app in local dev so multiple Payload apps
|
|
3
|
+
* running on localhost (shared cookie jar across ports) don't clobber each
|
|
4
|
+
* other's sessions on logout. Uses projectId so the cookie stays stable when
|
|
5
|
+
* switching environments in the same checkout; falls back to contentSystemId
|
|
6
|
+
* when projectId isn't in `.env`.
|
|
7
|
+
*
|
|
8
|
+
* In production, cookies are isolated by unique hostnames and this is unused.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getDevCookieNames(contentSystemId: string): {
|
|
11
|
+
cookieName: string;
|
|
12
|
+
userInfoCookieName: string;
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=dev-cookie-names.d.ts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { getEnvVarSync } from '../utils/env-management.js';
|
|
2
|
+
/**
|
|
3
|
+
* Namespace OAuth cookies per-app in local dev so multiple Payload apps
|
|
4
|
+
* running on localhost (shared cookie jar across ports) don't clobber each
|
|
5
|
+
* other's sessions on logout. Uses projectId so the cookie stays stable when
|
|
6
|
+
* switching environments in the same checkout; falls back to contentSystemId
|
|
7
|
+
* when projectId isn't in `.env`.
|
|
8
|
+
*
|
|
9
|
+
* In production, cookies are isolated by unique hostnames and this is unused.
|
|
10
|
+
*/ export function getDevCookieNames(contentSystemId) {
|
|
11
|
+
const projectId = process.env.FIGMA_PROJECT_ID ?? getEnvVarSync(process.cwd(), 'FIGMA_PROJECT_ID') ?? contentSystemId;
|
|
12
|
+
const suffix = projectId.slice(0, 8);
|
|
13
|
+
return {
|
|
14
|
+
cookieName: `figma-${suffix}-oauth-token`,
|
|
15
|
+
userInfoCookieName: `figma-${suffix}-user-info`
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=dev-cookie-names.js.map
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Upload API types extracted from Content API OpenAPI spec.
|
|
3
|
+
* These are kept separate to avoid breaking changes when the main spec is regenerated.
|
|
4
|
+
*/
|
|
5
|
+
export type UploadPaths = {
|
|
6
|
+
'/api/v0/uploads/{collectionId}/{filename}': {
|
|
7
|
+
delete: {
|
|
8
|
+
parameters: {
|
|
9
|
+
path: {
|
|
10
|
+
collectionId: string;
|
|
11
|
+
filename: string;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
responses: {
|
|
15
|
+
200: {
|
|
16
|
+
content: {
|
|
17
|
+
'application/json': {
|
|
18
|
+
success: true;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
'/api/v0/uploads/download/sign': {
|
|
26
|
+
post: {
|
|
27
|
+
requestBody: {
|
|
28
|
+
content: {
|
|
29
|
+
'application/json': {
|
|
30
|
+
collectionId: string;
|
|
31
|
+
expiresIn: number;
|
|
32
|
+
filename: string;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
responses: {
|
|
37
|
+
200: {
|
|
38
|
+
content: {
|
|
39
|
+
'application/json': {
|
|
40
|
+
url: string;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
'/api/v0/uploads/multipart/abort': {
|
|
48
|
+
post: {
|
|
49
|
+
requestBody: {
|
|
50
|
+
content: {
|
|
51
|
+
'application/json': {
|
|
52
|
+
collectionId: string;
|
|
53
|
+
filename: string;
|
|
54
|
+
uploadId: string;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
responses: {
|
|
59
|
+
200: {
|
|
60
|
+
content: {
|
|
61
|
+
'application/json': {
|
|
62
|
+
success: true;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
'/api/v0/uploads/multipart/complete': {
|
|
70
|
+
post: {
|
|
71
|
+
requestBody: {
|
|
72
|
+
content: {
|
|
73
|
+
'application/json': {
|
|
74
|
+
collectionId: string;
|
|
75
|
+
filename: string;
|
|
76
|
+
parts: Array<{
|
|
77
|
+
ETag: string;
|
|
78
|
+
PartNumber: number;
|
|
79
|
+
}>;
|
|
80
|
+
uploadId: string;
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
responses: {
|
|
85
|
+
200: {
|
|
86
|
+
content: {
|
|
87
|
+
'application/json': {
|
|
88
|
+
success: true;
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
'/api/v0/uploads/multipart/initiate': {
|
|
96
|
+
post: {
|
|
97
|
+
requestBody: {
|
|
98
|
+
content: {
|
|
99
|
+
'application/json': {
|
|
100
|
+
collectionId: string;
|
|
101
|
+
contentType: string;
|
|
102
|
+
filename: string;
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
responses: {
|
|
107
|
+
200: {
|
|
108
|
+
content: {
|
|
109
|
+
'application/json': {
|
|
110
|
+
uploadId: string;
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
'/api/v0/uploads/multipart/parts': {
|
|
118
|
+
post: {
|
|
119
|
+
requestBody: {
|
|
120
|
+
content: {
|
|
121
|
+
'application/json': {
|
|
122
|
+
collectionId: string;
|
|
123
|
+
expiresIn: number;
|
|
124
|
+
filename: string;
|
|
125
|
+
partNumbers: number[];
|
|
126
|
+
uploadId: string;
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
responses: {
|
|
131
|
+
200: {
|
|
132
|
+
content: {
|
|
133
|
+
'application/json': {
|
|
134
|
+
parts: Array<{
|
|
135
|
+
partNumber: number;
|
|
136
|
+
url: string;
|
|
137
|
+
}>;
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
};
|
|
142
|
+
};
|
|
143
|
+
};
|
|
144
|
+
'/api/v0/uploads/sign': {
|
|
145
|
+
post: {
|
|
146
|
+
requestBody: {
|
|
147
|
+
content: {
|
|
148
|
+
'application/json': {
|
|
149
|
+
collectionId: string;
|
|
150
|
+
contentType?: string;
|
|
151
|
+
expiresIn: number;
|
|
152
|
+
filename: string;
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
};
|
|
156
|
+
responses: {
|
|
157
|
+
200: {
|
|
158
|
+
content: {
|
|
159
|
+
'application/json': {
|
|
160
|
+
url: string;
|
|
161
|
+
};
|
|
162
|
+
};
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
};
|
|
167
|
+
};
|
|
168
|
+
//# sourceMappingURL=api-types.d.ts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const ContentApiClientUploadHandler: ({ children, collectionSlug, enabled, extra, prefix, serverHandlerPath, }: {
|
|
2
|
+
children: import("react").ReactNode;
|
|
3
|
+
collectionSlug: import("payload").UploadCollectionSlug;
|
|
4
|
+
enabled?: boolean;
|
|
5
|
+
extra: Record<string, unknown>;
|
|
6
|
+
prefix?: string;
|
|
7
|
+
serverHandlerPath: `/${string}`;
|
|
8
|
+
}) => import("react").JSX.Element;
|
|
9
|
+
//# sourceMappingURL=ClientUploadHandler.d.ts.map
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { createClientUploadHandler } from '@payloadcms/plugin-cloud-storage/client';
|
|
3
|
+
export const ContentApiClientUploadHandler = createClientUploadHandler({
|
|
4
|
+
handler: async ({ apiRoute, collectionSlug, file, prefix, serverHandlerPath, serverURL })=>{
|
|
5
|
+
// Build endpoint URL: serverURL + apiRoute + serverHandlerPath
|
|
6
|
+
const endpointRoute = `${serverURL}${apiRoute}${serverHandlerPath}`;
|
|
7
|
+
const response = await fetch(endpointRoute, {
|
|
8
|
+
body: JSON.stringify({
|
|
9
|
+
collectionSlug,
|
|
10
|
+
filename: file.name,
|
|
11
|
+
mimeType: file.type
|
|
12
|
+
}),
|
|
13
|
+
credentials: 'include',
|
|
14
|
+
headers: {
|
|
15
|
+
'Content-Type': 'application/json'
|
|
16
|
+
},
|
|
17
|
+
method: 'POST'
|
|
18
|
+
});
|
|
19
|
+
if (!response.ok) {
|
|
20
|
+
throw new Error(`Failed to get presigned URL: ${response.status} ${response.statusText}`);
|
|
21
|
+
}
|
|
22
|
+
const { filename: safeFilename, url } = await response.json();
|
|
23
|
+
const uploadFilename = safeFilename || file.name;
|
|
24
|
+
const uploadResponse = await fetch(url, {
|
|
25
|
+
body: file,
|
|
26
|
+
headers: {
|
|
27
|
+
'Content-Type': file.type
|
|
28
|
+
},
|
|
29
|
+
method: 'PUT'
|
|
30
|
+
});
|
|
31
|
+
if (!uploadResponse.ok) {
|
|
32
|
+
throw new Error(`Failed to upload to S3: ${uploadResponse.status} ${uploadResponse.statusText}`);
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
clientUploaded: true,
|
|
36
|
+
filename: uploadFilename,
|
|
37
|
+
mimeType: file.type,
|
|
38
|
+
prefix
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
//# sourceMappingURL=ClientUploadHandler.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { PayloadHandler } from 'payload';
|
|
2
|
+
import type { StorageClient } from '../client.js';
|
|
3
|
+
type ClientUploadsAccess = (args: {
|
|
4
|
+
collectionSlug: string;
|
|
5
|
+
req: Parameters<PayloadHandler>[0];
|
|
6
|
+
}) => boolean | Promise<boolean>;
|
|
7
|
+
type Args = {
|
|
8
|
+
access?: ClientUploadsAccess;
|
|
9
|
+
client: StorageClient;
|
|
10
|
+
};
|
|
11
|
+
export declare const getGenerateSignedURLHandler: ({ access, client, }: Args) => PayloadHandler;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=generateSignedURL.d.ts.map
|