@payloadcms/figma 0.0.1-alpha.7 → 0.0.1-alpha.71
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 +150 -12
- package/dist/oauth/components/LoginButton/index.scss +75 -3
- package/dist/oauth/components/LogoutButton/index.js +20 -7
- 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,39 @@
|
|
|
1
|
+
import { APIError, Forbidden } from 'payload';
|
|
2
|
+
import { getSafeFilename } from '../utilities/index.js';
|
|
3
|
+
const defaultAccess = ({ req })=>!!req.user;
|
|
4
|
+
export const getGenerateSignedURLHandler = ({ access = defaultAccess, client })=>{
|
|
5
|
+
return async (req)=>{
|
|
6
|
+
if (!req.json) {
|
|
7
|
+
throw new APIError('Content-Type expected to be application/json', 400);
|
|
8
|
+
}
|
|
9
|
+
const { collectionSlug, filename, mimeType } = await req.json();
|
|
10
|
+
if (!await access({
|
|
11
|
+
collectionSlug,
|
|
12
|
+
req
|
|
13
|
+
})) {
|
|
14
|
+
throw new Forbidden();
|
|
15
|
+
}
|
|
16
|
+
const safeFilename = await getSafeFilename({
|
|
17
|
+
collectionSlug,
|
|
18
|
+
desiredFilename: filename,
|
|
19
|
+
req
|
|
20
|
+
});
|
|
21
|
+
const { data, error } = await client.POST('/api/v0/uploads/sign', {
|
|
22
|
+
body: {
|
|
23
|
+
collectionId: collectionSlug,
|
|
24
|
+
contentType: mimeType,
|
|
25
|
+
expiresIn: 3600,
|
|
26
|
+
filename: safeFilename
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
if (error || !data) {
|
|
30
|
+
throw new APIError(`Failed to get presigned upload URL: ${JSON.stringify(error)}`);
|
|
31
|
+
}
|
|
32
|
+
return Response.json({
|
|
33
|
+
filename: safeFilename,
|
|
34
|
+
url: data.url
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
//# sourceMappingURL=generateSignedURL.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import createClient from 'openapi-fetch';
|
|
2
|
+
import type { UploadPaths } from './api-types.js';
|
|
3
|
+
import type { StorageClientConfig } from './types.js';
|
|
4
|
+
export type StorageClient = ReturnType<typeof createClient<UploadPaths>>;
|
|
5
|
+
export declare function createStorageClient(config: StorageClientConfig): StorageClient;
|
|
6
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import createClient from 'openapi-fetch';
|
|
2
|
+
import { getValidProjectToken } from '../auth/project-token.js';
|
|
3
|
+
import { fetchDevJwt } from '../db-content-api/utilities/auth.js';
|
|
4
|
+
export function createStorageClient(config) {
|
|
5
|
+
const client = createClient({
|
|
6
|
+
baseUrl: config.baseUrl
|
|
7
|
+
});
|
|
8
|
+
client.use(createStorageAuthMiddleware(config));
|
|
9
|
+
return client;
|
|
10
|
+
}
|
|
11
|
+
function createStorageAuthMiddleware(config) {
|
|
12
|
+
return {
|
|
13
|
+
async onRequest ({ request }) {
|
|
14
|
+
if ('contentApiKey' in config) {
|
|
15
|
+
request.headers.set('X-Api-Key', config.contentApiKey);
|
|
16
|
+
} else {
|
|
17
|
+
const { auth, contentSystemId } = config;
|
|
18
|
+
if (auth.mode === 'apiKey') {
|
|
19
|
+
request.headers.set('X-Api-Key', auth.apiKey);
|
|
20
|
+
} else if (auth.mode === 'tokenStore') {
|
|
21
|
+
const token = await getValidProjectToken({
|
|
22
|
+
tenantId: contentSystemId,
|
|
23
|
+
tokenStore: auth.tokenStore
|
|
24
|
+
});
|
|
25
|
+
if (!token) {
|
|
26
|
+
throw new Error('Authentication required. Run `npx @payloadcms/figma login` to authenticate.');
|
|
27
|
+
}
|
|
28
|
+
request.headers.set('Authorization', `Bearer ${token}`);
|
|
29
|
+
} else {
|
|
30
|
+
const token = await fetchDevJwt(config.baseUrl, contentSystemId);
|
|
31
|
+
request.headers.set('Authorization', `Bearer ${token}`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return request;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
export const getGenerateURL = ({ baseUrl })=>({ collection, filename, prefix = '' })=>{
|
|
3
|
+
const collectionId = collection.slug;
|
|
4
|
+
const fileKey = path.posix.join(prefix, filename);
|
|
5
|
+
return `${baseUrl}/api/v0/uploads/download/${collectionId}/${encodeURIComponent(fileKey)}`;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
//# sourceMappingURL=generateURL.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { HandleDelete } from '@payloadcms/plugin-cloud-storage/types';
|
|
2
|
+
import type { StorageClient } from './client.js';
|
|
3
|
+
type Args = {
|
|
4
|
+
client: StorageClient;
|
|
5
|
+
};
|
|
6
|
+
export declare const getHandleDelete: ({ client }: Args) => HandleDelete;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=handleDelete.d.ts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
export const getHandleDelete = ({ client })=>{
|
|
3
|
+
return async ({ collection, doc: { prefix = '' }, filename })=>{
|
|
4
|
+
const collectionId = collection.slug;
|
|
5
|
+
const fileKey = path.posix.join(prefix, filename);
|
|
6
|
+
await client.DELETE('/api/v0/uploads/{collectionId}/{filename}', {
|
|
7
|
+
params: {
|
|
8
|
+
path: {
|
|
9
|
+
collectionId,
|
|
10
|
+
filename: fileKey
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=handleDelete.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { HandleUpload } from '@payloadcms/plugin-cloud-storage/types';
|
|
2
|
+
import type { CollectionConfig } from 'payload';
|
|
3
|
+
import type { StorageClient } from './client.js';
|
|
4
|
+
type Args = {
|
|
5
|
+
client: StorageClient;
|
|
6
|
+
collection: CollectionConfig;
|
|
7
|
+
prefix?: string;
|
|
8
|
+
};
|
|
9
|
+
export declare const getHandleUpload: ({ client, collection, prefix }: Args) => HandleUpload;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=handleUpload.d.ts.map
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { parseClientUploadContext } from './utilities/index.js';
|
|
4
|
+
const PART_SIZE = 64 * 1024 * 1024 // 64MB per part
|
|
5
|
+
;
|
|
6
|
+
const MAX_FILE_SIZE_BEFORE_MULTIPART = 100 * 1024 * 1024 // 100MB
|
|
7
|
+
;
|
|
8
|
+
export const getHandleUpload = ({ client, collection, prefix = '' })=>{
|
|
9
|
+
return async ({ clientUploadContext, data, file })=>{
|
|
10
|
+
// Skip if the client already uploaded THIS SPECIFIC file. Resized versions
|
|
11
|
+
// (different filename) should still be uploaded.
|
|
12
|
+
const context = parseClientUploadContext(clientUploadContext);
|
|
13
|
+
const isOriginalClientUploaded = context.clientUploaded === true && file.filename === context.filename;
|
|
14
|
+
if (isOriginalClientUploaded) {
|
|
15
|
+
return data;
|
|
16
|
+
}
|
|
17
|
+
const collectionId = collection.slug;
|
|
18
|
+
const fileKey = path.posix.join(data.prefix || prefix, file.filename);
|
|
19
|
+
const fileData = file.tempFilePath ? fs.readFileSync(file.tempFilePath) : file.buffer;
|
|
20
|
+
const fileSize = file.filesize || fileData.length;
|
|
21
|
+
if (fileSize > MAX_FILE_SIZE_BEFORE_MULTIPART) {
|
|
22
|
+
await uploadMultipart({
|
|
23
|
+
client,
|
|
24
|
+
collectionId,
|
|
25
|
+
fileData,
|
|
26
|
+
fileKey,
|
|
27
|
+
mimeType: file.mimeType
|
|
28
|
+
});
|
|
29
|
+
} else {
|
|
30
|
+
await uploadSingleFile({
|
|
31
|
+
client,
|
|
32
|
+
collectionId,
|
|
33
|
+
fileData,
|
|
34
|
+
fileKey,
|
|
35
|
+
mimeType: file.mimeType
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
return data;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
async function uploadSingleFile({ client, collectionId, fileData, fileKey, mimeType }) {
|
|
42
|
+
const { data, error } = await client.POST('/api/v0/uploads/sign', {
|
|
43
|
+
body: {
|
|
44
|
+
collectionId,
|
|
45
|
+
contentType: mimeType,
|
|
46
|
+
expiresIn: 3600,
|
|
47
|
+
filename: fileKey
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
if (error || !data) {
|
|
51
|
+
throw new Error(`Failed to get presigned upload URL: ${JSON.stringify(error)}`);
|
|
52
|
+
}
|
|
53
|
+
const uploadResponse = await fetch(data.url, {
|
|
54
|
+
body: fileData,
|
|
55
|
+
headers: {
|
|
56
|
+
'Content-Type': mimeType
|
|
57
|
+
},
|
|
58
|
+
method: 'PUT'
|
|
59
|
+
});
|
|
60
|
+
if (!uploadResponse.ok) {
|
|
61
|
+
throw new Error(`Failed to upload to S3: ${uploadResponse.status} ${uploadResponse.statusText}`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
async function uploadMultipart({ client, collectionId, fileData, fileKey, mimeType }) {
|
|
65
|
+
const { data: initiateData, error: initiateError } = await client.POST('/api/v0/uploads/multipart/initiate', {
|
|
66
|
+
body: {
|
|
67
|
+
collectionId,
|
|
68
|
+
contentType: mimeType,
|
|
69
|
+
filename: fileKey
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
if (initiateError || !initiateData) {
|
|
73
|
+
throw new Error(`Failed to initiate multipart upload: ${JSON.stringify(initiateError)}`);
|
|
74
|
+
}
|
|
75
|
+
const { uploadId } = initiateData;
|
|
76
|
+
try {
|
|
77
|
+
const numParts = Math.ceil(fileData.length / PART_SIZE);
|
|
78
|
+
const partNumbers = Array.from({
|
|
79
|
+
length: numParts
|
|
80
|
+
}, (_, i)=>i + 1);
|
|
81
|
+
const { data: partsData, error: partsError } = await client.POST('/api/v0/uploads/multipart/parts', {
|
|
82
|
+
body: {
|
|
83
|
+
collectionId,
|
|
84
|
+
expiresIn: 3600,
|
|
85
|
+
filename: fileKey,
|
|
86
|
+
partNumbers,
|
|
87
|
+
uploadId
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
if (partsError || !partsData) {
|
|
91
|
+
throw new Error(`Failed to get part URLs: ${JSON.stringify(partsError)}`);
|
|
92
|
+
}
|
|
93
|
+
const { parts } = partsData;
|
|
94
|
+
if (!parts || !Array.isArray(parts)) {
|
|
95
|
+
throw new Error('Invalid response from part URLs endpoint: parts is not an array');
|
|
96
|
+
}
|
|
97
|
+
const uploadedParts = await Promise.all(parts.map(async ({ partNumber, url })=>{
|
|
98
|
+
const start = (partNumber - 1) * PART_SIZE;
|
|
99
|
+
const end = Math.min(start + PART_SIZE, fileData.length);
|
|
100
|
+
const partData = fileData.slice(start, end);
|
|
101
|
+
const uploadResponse = await fetch(url, {
|
|
102
|
+
body: partData,
|
|
103
|
+
headers: {
|
|
104
|
+
'Content-Type': mimeType
|
|
105
|
+
},
|
|
106
|
+
method: 'PUT'
|
|
107
|
+
});
|
|
108
|
+
const etag = uploadResponse.headers.get('ETag');
|
|
109
|
+
if (!etag) {
|
|
110
|
+
throw new Error(`No ETag returned for part ${partNumber}`);
|
|
111
|
+
}
|
|
112
|
+
return {
|
|
113
|
+
ETag: etag,
|
|
114
|
+
PartNumber: partNumber
|
|
115
|
+
};
|
|
116
|
+
}));
|
|
117
|
+
const { error: completeError } = await client.POST('/api/v0/uploads/multipart/complete', {
|
|
118
|
+
body: {
|
|
119
|
+
collectionId,
|
|
120
|
+
filename: fileKey,
|
|
121
|
+
parts: uploadedParts,
|
|
122
|
+
uploadId
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
if (completeError) {
|
|
126
|
+
throw new Error(`Failed to complete multipart upload: ${JSON.stringify(completeError)}`);
|
|
127
|
+
}
|
|
128
|
+
} catch (error) {
|
|
129
|
+
try {
|
|
130
|
+
await client.POST('/api/v0/uploads/multipart/abort', {
|
|
131
|
+
body: {
|
|
132
|
+
collectionId,
|
|
133
|
+
filename: fileKey,
|
|
134
|
+
uploadId
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
} catch {
|
|
138
|
+
// Ignore abort errors
|
|
139
|
+
}
|
|
140
|
+
throw error;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
//# sourceMappingURL=handleUpload.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Adapter } from '@payloadcms/plugin-cloud-storage/types';
|
|
2
|
+
import type { StorageClientConfig } from './types.js';
|
|
3
|
+
export type { StorageClientConfig } from './types.js';
|
|
4
|
+
export declare function contentApiStorageAdapter(config: StorageClientConfig): Adapter;
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { createStorageClient } from './client.js';
|
|
2
|
+
import { getGenerateURL } from './generateURL.js';
|
|
3
|
+
import { getHandleDelete } from './handleDelete.js';
|
|
4
|
+
import { getHandleUpload } from './handleUpload.js';
|
|
5
|
+
import { getHandler } from './staticHandler.js';
|
|
6
|
+
export function contentApiStorageAdapter(config) {
|
|
7
|
+
return ({ collection, prefix })=>{
|
|
8
|
+
const client = createStorageClient(config);
|
|
9
|
+
const baseUrl = config.baseUrl;
|
|
10
|
+
return {
|
|
11
|
+
name: 'content-api',
|
|
12
|
+
generateURL: getGenerateURL({
|
|
13
|
+
baseUrl
|
|
14
|
+
}),
|
|
15
|
+
handleDelete: getHandleDelete({
|
|
16
|
+
client
|
|
17
|
+
}),
|
|
18
|
+
handleUpload: getHandleUpload({
|
|
19
|
+
client,
|
|
20
|
+
collection,
|
|
21
|
+
prefix
|
|
22
|
+
}),
|
|
23
|
+
staticHandler: getHandler({
|
|
24
|
+
client,
|
|
25
|
+
collection
|
|
26
|
+
})
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { StaticHandler } from '@payloadcms/plugin-cloud-storage/types';
|
|
2
|
+
import type { CollectionConfig } from 'payload';
|
|
3
|
+
import type { StorageClient } from './client.js';
|
|
4
|
+
type Args = {
|
|
5
|
+
client: StorageClient;
|
|
6
|
+
collection: CollectionConfig;
|
|
7
|
+
};
|
|
8
|
+
export declare const getHandler: ({ client, collection }: Args) => StaticHandler;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=staticHandler.d.ts.map
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { getFilePrefix } from '@payloadcms/plugin-cloud-storage/utilities';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { isImage } from 'payload/shared';
|
|
4
|
+
import { parseClientUploadContext } from './utilities/index.js';
|
|
5
|
+
export const getHandler = ({ client, collection })=>{
|
|
6
|
+
return async (req, { params: { clientUploadContext, filename } })=>{
|
|
7
|
+
try {
|
|
8
|
+
const prefix = await getFilePrefix({
|
|
9
|
+
clientUploadContext,
|
|
10
|
+
collection,
|
|
11
|
+
filename,
|
|
12
|
+
req
|
|
13
|
+
});
|
|
14
|
+
const key = path.posix.join(prefix, filename);
|
|
15
|
+
const { data, error } = await client.POST('/api/v0/uploads/download/sign', {
|
|
16
|
+
body: {
|
|
17
|
+
collectionId: collection.slug,
|
|
18
|
+
expiresIn: 7200,
|
|
19
|
+
filename: key
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
if (error || !data) {
|
|
23
|
+
req.payload.logger.error(`Failed to get signed download URL: ${JSON.stringify(error)}`);
|
|
24
|
+
return new Response('Internal Server Error', {
|
|
25
|
+
status: 500
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
// On a client-upload fetch-back, core reads this response body into req.file.data to
|
|
29
|
+
// size the image; a 302's empty body crashes getImageSize. Return real bytes for
|
|
30
|
+
// images (and unknown mimetypes, to be safe), but keep the redirect otherwise so we
|
|
31
|
+
// don't download large non-images server-side.
|
|
32
|
+
if (clientUploadContext) {
|
|
33
|
+
const { mimeType } = parseClientUploadContext(clientUploadContext);
|
|
34
|
+
if (!mimeType || isImage(mimeType)) {
|
|
35
|
+
const fileResponse = await fetch(data.url);
|
|
36
|
+
if (!fileResponse.ok) {
|
|
37
|
+
req.payload.logger.error(`Failed to fetch file for client-upload buffer fetch-back: ${fileResponse.status}`);
|
|
38
|
+
return new Response('Internal Server Error', {
|
|
39
|
+
status: 500
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
const contentType = fileResponse.headers.get('Content-Type') ?? mimeType ?? 'application/octet-stream';
|
|
43
|
+
return new Response(await fileResponse.arrayBuffer(), {
|
|
44
|
+
headers: {
|
|
45
|
+
'Content-Type': contentType
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return Response.redirect(data.url, 302);
|
|
51
|
+
} catch (err) {
|
|
52
|
+
req.payload.logger.error({
|
|
53
|
+
err,
|
|
54
|
+
msg: 'Error in staticHandler'
|
|
55
|
+
});
|
|
56
|
+
return new Response('Internal Server Error', {
|
|
57
|
+
status: 500
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
//# sourceMappingURL=staticHandler.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AuthMode } from '../db-content-api/utilities/auth.js';
|
|
2
|
+
export type StorageClientConfig = {
|
|
3
|
+
auth: AuthMode;
|
|
4
|
+
baseUrl: string;
|
|
5
|
+
contentSystemId: string;
|
|
6
|
+
} | {
|
|
7
|
+
baseUrl: string;
|
|
8
|
+
contentApiKey: string;
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { PayloadRequest } from 'payload';
|
|
2
|
+
/**
|
|
3
|
+
* Get a safe filename that doesn't collide with existing documents
|
|
4
|
+
* Similar to Payload's getSafeFileName
|
|
5
|
+
*/
|
|
6
|
+
export declare function getSafeFilename({ collectionSlug, desiredFilename, prefix, req, }: {
|
|
7
|
+
collectionSlug: string;
|
|
8
|
+
desiredFilename: string;
|
|
9
|
+
prefix?: string;
|
|
10
|
+
req: PayloadRequest;
|
|
11
|
+
}): Promise<string>;
|
|
12
|
+
//# sourceMappingURL=getSafeFilename.d.ts.map
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import sanitize from 'sanitize-filename';
|
|
2
|
+
/**
|
|
3
|
+
* Check if a document with the given filename already exists in the database
|
|
4
|
+
* Matches Payload's docWithFilenameExists
|
|
5
|
+
*/ async function docWithFilenameExists({ collectionSlug, filename, prefix, req }) {
|
|
6
|
+
const where = {
|
|
7
|
+
filename: {
|
|
8
|
+
equals: filename
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
if (prefix) {
|
|
12
|
+
where.prefix = {
|
|
13
|
+
equals: prefix
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
const doc = await req.payload.db.findOne({
|
|
17
|
+
collection: collectionSlug,
|
|
18
|
+
req,
|
|
19
|
+
where
|
|
20
|
+
});
|
|
21
|
+
return !!doc;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Increment filename by adding -1, -2, etc. suffix
|
|
25
|
+
* photo.jpg → photo-1.jpg
|
|
26
|
+
* photo-1.jpg → photo-2.jpg
|
|
27
|
+
* Matches Payload's incrementName
|
|
28
|
+
*/ function incrementFilename(name) {
|
|
29
|
+
const extension = name.split('.').pop();
|
|
30
|
+
const baseFilename = sanitize(name.substring(0, name.lastIndexOf('.')) || name);
|
|
31
|
+
let incrementedName = baseFilename;
|
|
32
|
+
const regex = /(.*)-(\d+)$/;
|
|
33
|
+
const found = baseFilename.match(regex);
|
|
34
|
+
if (found === null) {
|
|
35
|
+
incrementedName += '-1';
|
|
36
|
+
} else {
|
|
37
|
+
const matchedName = found[1];
|
|
38
|
+
const matchedNumber = found[2];
|
|
39
|
+
const incremented = Number(matchedNumber) + 1;
|
|
40
|
+
incrementedName = `${matchedName}-${incremented}`;
|
|
41
|
+
}
|
|
42
|
+
return `${incrementedName}.${extension}`;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Get a safe filename that doesn't collide with existing documents
|
|
46
|
+
* Similar to Payload's getSafeFileName
|
|
47
|
+
*/ export async function getSafeFilename({ collectionSlug, desiredFilename, prefix, req }) {
|
|
48
|
+
let modifiedFilename = desiredFilename;
|
|
49
|
+
// Keep incrementing until we find a filename that doesn't exist
|
|
50
|
+
while(await docWithFilenameExists({
|
|
51
|
+
collectionSlug,
|
|
52
|
+
filename: modifiedFilename,
|
|
53
|
+
prefix,
|
|
54
|
+
req
|
|
55
|
+
})){
|
|
56
|
+
modifiedFilename = incrementFilename(modifiedFilename);
|
|
57
|
+
}
|
|
58
|
+
return modifiedFilename;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
//# sourceMappingURL=getSafeFilename.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The shape of the `clientUploadContext` produced by this adapter's client upload
|
|
3
|
+
* handler. The plugin's `StaticHandler`/`HandleUpload` types expose it as `unknown`
|
|
4
|
+
* (it is deserialized from a JSON form field and is adapter-specific), so it must be
|
|
5
|
+
* narrowed at runtime before use.
|
|
6
|
+
*/
|
|
7
|
+
export type ContentApiClientUploadContext = {
|
|
8
|
+
clientUploaded?: boolean;
|
|
9
|
+
filename?: string;
|
|
10
|
+
mimeType?: string;
|
|
11
|
+
prefix?: string;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Safely narrows an `unknown` clientUploadContext into the adapter's known shape,
|
|
15
|
+
* keeping only properties that are actually present with the expected type. Returns
|
|
16
|
+
* an empty object for any non-object input.
|
|
17
|
+
*/
|
|
18
|
+
export declare const parseClientUploadContext: (context: unknown) => ContentApiClientUploadContext;
|
|
19
|
+
//# sourceMappingURL=parseClientUploadContext.d.ts.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The shape of the `clientUploadContext` produced by this adapter's client upload
|
|
3
|
+
* handler. The plugin's `StaticHandler`/`HandleUpload` types expose it as `unknown`
|
|
4
|
+
* (it is deserialized from a JSON form field and is adapter-specific), so it must be
|
|
5
|
+
* narrowed at runtime before use.
|
|
6
|
+
*/ /**
|
|
7
|
+
* Safely narrows an `unknown` clientUploadContext into the adapter's known shape,
|
|
8
|
+
* keeping only properties that are actually present with the expected type. Returns
|
|
9
|
+
* an empty object for any non-object input.
|
|
10
|
+
*/ export const parseClientUploadContext = (context)=>{
|
|
11
|
+
if (!context || typeof context !== 'object') {
|
|
12
|
+
return {};
|
|
13
|
+
}
|
|
14
|
+
const result = {};
|
|
15
|
+
if ('clientUploaded' in context && typeof context.clientUploaded === 'boolean') {
|
|
16
|
+
result.clientUploaded = context.clientUploaded;
|
|
17
|
+
}
|
|
18
|
+
if ('filename' in context && typeof context.filename === 'string') {
|
|
19
|
+
result.filename = context.filename;
|
|
20
|
+
}
|
|
21
|
+
if ('mimeType' in context && typeof context.mimeType === 'string') {
|
|
22
|
+
result.mimeType = context.mimeType;
|
|
23
|
+
}
|
|
24
|
+
if ('prefix' in context && typeof context.prefix === 'string') {
|
|
25
|
+
result.prefix = context.prefix;
|
|
26
|
+
}
|
|
27
|
+
return result;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=parseClientUploadContext.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# {{PROJECT_NAME}}
|
|
2
|
+
|
|
3
|
+
A Payload project configured for running on Figma infrastructure.
|
|
4
|
+
|
|
5
|
+
## Getting Started
|
|
6
|
+
|
|
7
|
+
{{RUN_COMMAND}} dev
|
|
8
|
+
|
|
9
|
+
Open http://localhost:3000/admin to access the admin panel.
|
|
10
|
+
|
|
11
|
+
## Deployment
|
|
12
|
+
|
|
13
|
+
npx @payloadcms/figma deploy
|
|
14
|
+
|
|
15
|
+
Deploys to Figma infrastructure.
|
|
16
|
+
|
|
17
|
+
## Resources
|
|
18
|
+
|
|
19
|
+
- [Payload Docs](https://payloadcms.com/docs)
|
package/dist/types/config.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Figma CMS Configuration Types
|
|
3
3
|
*/
|
|
4
|
+
import type { PackageManager } from '../utils/package-manager.js';
|
|
4
5
|
/**
|
|
5
6
|
* Tenant instance from Control Plane API
|
|
6
7
|
*/
|
|
@@ -25,7 +26,7 @@ export interface ProjectInfo {
|
|
|
25
26
|
/** Whether Payload is installed */
|
|
26
27
|
hasPayload: boolean;
|
|
27
28
|
/** Package manager detected (npm, pnpm, yarn) */
|
|
28
|
-
packageManager?:
|
|
29
|
+
packageManager?: PackageManager;
|
|
29
30
|
/** Project root path */
|
|
30
31
|
path: string;
|
|
31
32
|
/** Payload version if installed */
|
package/dist/types/config.js
CHANGED
package/dist/types.d.ts
CHANGED
|
@@ -1,13 +1,23 @@
|
|
|
1
1
|
import type arg from 'arg';
|
|
2
2
|
export interface Args extends arg.Spec {
|
|
3
3
|
'--debug': BooleanConstructor;
|
|
4
|
+
'--dry-run': BooleanConstructor;
|
|
5
|
+
'--env': StringConstructor;
|
|
6
|
+
'--environment': string;
|
|
4
7
|
'--force': BooleanConstructor;
|
|
5
8
|
'--help': BooleanConstructor;
|
|
9
|
+
'--id': StringConstructor;
|
|
10
|
+
'--infra-env': StringConstructor;
|
|
6
11
|
'--list': BooleanConstructor;
|
|
7
12
|
'--logout': BooleanConstructor;
|
|
13
|
+
'--name': StringConstructor;
|
|
14
|
+
'--template': StringConstructor;
|
|
8
15
|
'--yes': BooleanConstructor;
|
|
16
|
+
'-e': string;
|
|
9
17
|
'-f': string;
|
|
10
18
|
'-h': string;
|
|
19
|
+
'-n': string;
|
|
20
|
+
'-t': string;
|
|
11
21
|
'-y': string;
|
|
12
22
|
}
|
|
13
23
|
export type CliArgs = arg.Result<Args>;
|
|
@@ -37,7 +47,6 @@ interface Template {
|
|
|
37
47
|
name: string;
|
|
38
48
|
type: ProjectTemplate['type'];
|
|
39
49
|
}
|
|
40
|
-
export type PackageManager = 'bun' | 'npm' | 'pnpm' | 'yarn';
|
|
41
50
|
export type DbType = 'd1-sqlite' | 'mongodb' | 'postgres' | 'sqlite' | 'vercel-postgres';
|
|
42
51
|
export type DbDetails = {
|
|
43
52
|
dbUri?: string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { AssetCollection, DeployAdapter, PageCollection } from '../deploy-adapter.js';
|
|
2
|
+
export declare class NextjsAdapter implements DeployAdapter {
|
|
3
|
+
name: "nextjs";
|
|
4
|
+
collectAssets(projectPath: string): Promise<AssetCollection>;
|
|
5
|
+
collectPages(projectPath: string): Promise<PageCollection>;
|
|
6
|
+
prepareLambdaBundle(projectPath: string): Promise<string>;
|
|
7
|
+
}
|
|
8
|
+
export declare const nextjsAdapter: NextjsAdapter;
|
|
9
|
+
//# sourceMappingURL=nextjs.d.ts.map
|