@payloadcms/figma 0.0.1-alpha.9 → 0.1.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/control-plane.d.ts +56 -7
- package/dist/api/control-plane.js +188 -74
- package/dist/api/error-response.d.ts +36 -0
- package/dist/api/error-response.js +66 -0
- package/dist/api/figma-api.d.ts +24 -3
- package/dist/api/figma-api.js +110 -34
- package/dist/auth/browser.d.ts +0 -1
- package/dist/auth/browser.js +0 -2
- package/dist/auth/callback-server.d.ts +19 -8
- package/dist/auth/callback-server.js +72 -32
- package/dist/auth/credentials.d.ts +20 -0
- package/dist/auth/credentials.js +19 -0
- package/dist/auth/crypto-utils.d.ts +28 -1
- package/dist/auth/crypto-utils.js +132 -23
- package/dist/auth/jwt-validator.d.ts +23 -6
- package/dist/auth/jwt-validator.js +35 -9
- package/dist/auth/oauth-flow.d.ts +19 -4
- package/dist/auth/oauth-flow.js +151 -34
- package/dist/auth/paste-code.d.ts +33 -0
- package/dist/auth/paste-code.js +87 -0
- package/dist/auth/pkce.d.ts +0 -1
- package/dist/auth/pkce.js +0 -2
- package/dist/auth/project-token.d.ts +32 -17
- package/dist/auth/project-token.js +176 -68
- package/dist/auth/refresh.d.ts +2 -2
- package/dist/auth/refresh.js +25 -14
- package/dist/auth/token-store-migration.d.ts +57 -0
- package/dist/auth/token-store-migration.js +154 -0
- package/dist/auth/token-store.d.ts +63 -98
- package/dist/auth/token-store.js +405 -124
- package/dist/auth/types.d.ts +40 -6
- package/dist/auth/types.js +1 -3
- package/dist/cli.d.ts +0 -1
- package/dist/cli.js +102 -8
- package/dist/commands/bootstrap.d.ts +17 -0
- package/dist/commands/bootstrap.js +88 -0
- package/dist/commands/build-lambda-zip.d.ts +4 -0
- package/dist/commands/build-lambda-zip.js +17 -0
- package/dist/commands/debug.d.ts +7 -0
- package/dist/commands/debug.js +178 -0
- package/dist/commands/deploy.d.ts +11 -1
- package/dist/commands/deploy.js +193 -153
- package/dist/commands/dump-tokens.d.ts +11 -0
- package/dist/commands/dump-tokens.js +67 -0
- package/dist/commands/env.d.ts +12 -0
- package/dist/commands/env.js +86 -0
- package/dist/commands/init.d.ts +9 -6
- package/dist/commands/init.js +232 -152
- package/dist/commands/list-tokens.d.ts +3 -4
- package/dist/commands/list-tokens.js +24 -11
- package/dist/commands/login.d.ts +8 -2
- package/dist/commands/login.js +34 -18
- package/dist/commands/logout.d.ts +5 -5
- package/dist/commands/logout.js +77 -17
- package/dist/commands/upgrade.d.ts +4 -0
- package/dist/commands/upgrade.js +329 -0
- package/dist/commands/upload-schema.d.ts +8 -0
- package/dist/commands/upload-schema.js +91 -0
- package/dist/config/oauth.d.ts +17 -12
- package/dist/config/oauth.js +38 -39
- package/dist/constants.d.ts +63 -19
- package/dist/constants.js +158 -20
- package/dist/db-content-api/generated/content-api-types.d.ts +7574 -0
- package/dist/db-content-api/generated/content-api-types.js +5 -0
- package/dist/db-content-api/index.d.ts +37 -0
- package/dist/db-content-api/index.js +938 -0
- package/dist/db-content-api/temp-utilities/slug.d.ts +1 -0
- package/dist/db-content-api/temp-utilities/slug.js +1 -0
- package/dist/db-content-api/temp-utilities/sorting.d.ts +2 -0
- package/dist/db-content-api/temp-utilities/sorting.js +37 -0
- package/dist/db-content-api/temp-utilities/types.d.ts +21 -0
- package/dist/db-content-api/temp-utilities/types.js +13 -0
- package/dist/db-content-api/temp-utilities/unwrapDocument.d.ts +38 -0
- package/dist/db-content-api/temp-utilities/unwrapDocument.js +62 -0
- package/dist/db-content-api/utilities/auth.d.ts +29 -0
- package/dist/db-content-api/utilities/auth.js +82 -0
- package/dist/db-content-api/utilities/data/applyDefaults.d.ts +6 -0
- package/dist/db-content-api/utilities/data/applyDefaults.js +75 -0
- package/dist/db-content-api/utilities/data/castFieldValue.d.ts +10 -0
- package/dist/db-content-api/utilities/data/castFieldValue.js +66 -0
- package/dist/db-content-api/utilities/data/index.d.ts +48 -0
- package/dist/db-content-api/utilities/data/index.js +299 -0
- package/dist/db-content-api/utilities/data/pointShape.d.ts +3 -0
- package/dist/db-content-api/utilities/data/pointShape.js +43 -0
- package/dist/db-content-api/utilities/data/removeVirtualFields.d.ts +11 -0
- package/dist/db-content-api/utilities/data/removeVirtualFields.js +52 -0
- package/dist/db-content-api/utilities/data/richTextShape.d.ts +3 -0
- package/dist/db-content-api/utilities/data/richTextShape.js +56 -0
- package/dist/db-content-api/utilities/data/stripFields.d.ts +47 -0
- package/dist/db-content-api/utilities/data/stripFields.js +170 -0
- package/dist/db-content-api/utilities/data/transformPublishedLocale.d.ts +22 -0
- package/dist/db-content-api/utilities/data/transformPublishedLocale.js +40 -0
- package/dist/db-content-api/utilities/data/validateRelationships.d.ts +6 -0
- package/dist/db-content-api/utilities/data/validateRelationships.js +100 -0
- package/dist/db-content-api/utilities/joins.d.ts +52 -0
- package/dist/db-content-api/utilities/joins.js +137 -0
- package/dist/db-content-api/utilities/locale/index.d.ts +9 -0
- package/dist/db-content-api/utilities/locale/index.js +19 -0
- package/dist/db-content-api/utilities/meta/buildLocalizedPaths.d.ts +10 -0
- package/dist/db-content-api/utilities/meta/buildLocalizedPaths.js +71 -0
- package/dist/db-content-api/utilities/meta/buildMeta.d.ts +41 -0
- package/dist/db-content-api/utilities/meta/buildMeta.js +39 -0
- package/dist/db-content-api/utilities/meta/buildPathTypes.d.ts +16 -0
- package/dist/db-content-api/utilities/meta/buildPathTypes.js +243 -0
- package/dist/db-content-api/utilities/meta/buildUniquePaths.d.ts +12 -0
- package/dist/db-content-api/utilities/meta/buildUniquePaths.js +60 -0
- package/dist/db-content-api/utilities/meta/normalizeLocaleInWhere.d.ts +9 -0
- package/dist/db-content-api/utilities/meta/normalizeLocaleInWhere.js +100 -0
- package/dist/db-content-api/utilities/resolveBlocks.d.ts +19 -0
- package/dist/db-content-api/utilities/resolveBlocks.js +31 -0
- package/dist/db-content-api/utilities/schema/buildDocumentSchema.d.ts +55 -0
- package/dist/db-content-api/utilities/schema/buildDocumentSchema.js +182 -0
- package/dist/db-content-api/utilities/where.d.ts +19 -0
- package/dist/db-content-api/utilities/where.js +106 -0
- package/dist/deploy/schedule-extract-plugin.d.ts +10 -0
- package/dist/deploy/schedule-extract-plugin.js +32 -0
- package/dist/endpoints/health.d.ts +2 -0
- package/dist/endpoints/health.js +9 -0
- package/dist/endpoints/schema.d.ts +2 -0
- package/dist/endpoints/schema.js +27 -0
- package/dist/exports/client.d.ts +2 -1
- package/dist/exports/client.js +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -3
- package/dist/lib/download-skill.d.ts +12 -0
- package/dist/lib/download-skill.js +77 -0
- package/dist/oauth/components/FigmaAvatar/index.d.ts +3 -0
- package/dist/oauth/components/FigmaAvatar/index.js +25 -0
- package/dist/oauth/components/FigmaAvatar/index.scss +12 -0
- package/dist/oauth/components/FigmaAvatarCell/index.d.ts +4 -0
- package/dist/oauth/components/FigmaAvatarCell/index.js +23 -0
- package/dist/oauth/components/FigmaAvatarCell/index.scss +5 -0
- package/dist/oauth/components/FigmaAvatarPlaceholder/index.d.ts +8 -0
- package/dist/oauth/components/FigmaAvatarPlaceholder/index.js +35 -0
- package/dist/oauth/components/FigmaAvatarPlaceholder/index.scss +28 -0
- package/dist/oauth/components/LoginButton/iframeAutoLogin.d.ts +81 -0
- package/dist/oauth/components/LoginButton/iframeAutoLogin.js +168 -0
- package/dist/oauth/components/LoginButton/index.d.ts +0 -1
- package/dist/oauth/components/LoginButton/index.js +156 -18
- package/dist/oauth/components/LoginButton/index.scss +75 -3
- package/dist/oauth/components/LogoutButton/index.d.ts +0 -1
- package/dist/oauth/components/LogoutButton/index.js +20 -9
- package/dist/oauth/defaults.d.ts +3 -2
- package/dist/oauth/defaults.js +79 -12
- package/dist/oauth/endpoints/getLoginEndpoint.d.ts +0 -1
- package/dist/oauth/endpoints/getLoginEndpoint.js +87 -84
- package/dist/oauth/endpoints/getLogoutEndpoint.d.ts +0 -1
- package/dist/oauth/endpoints/getLogoutEndpoint.js +7 -6
- package/dist/oauth/endpoints/getMetaEndpoint.d.ts +0 -1
- package/dist/oauth/endpoints/getMetaEndpoint.js +18 -5
- package/dist/oauth/endpoints/getRedirectToLoginEndpoint.d.ts +0 -1
- package/dist/oauth/endpoints/getRedirectToLoginEndpoint.js +11 -4
- package/dist/oauth/exports/client.d.ts +0 -1
- package/dist/oauth/exports/client.js +0 -2
- package/dist/oauth/hooks/afterLogout.d.ts +0 -1
- package/dist/oauth/hooks/afterLogout.js +0 -2
- package/dist/oauth/hooks/me.d.ts +0 -1
- package/dist/oauth/hooks/me.js +0 -2
- package/dist/oauth/hooks/refresh.d.ts +0 -1
- package/dist/oauth/hooks/refresh.js +2 -3
- package/dist/oauth/index.d.ts +0 -1
- package/dist/oauth/index.js +27 -7
- package/dist/oauth/strategy/index.d.ts +0 -3
- package/dist/oauth/strategy/index.js +55 -34
- package/dist/oauth/types.d.ts +23 -7
- package/dist/oauth/types.js +0 -2
- package/dist/oauth/utilities/buildUnauthorizedRedirect.d.ts +14 -0
- package/dist/oauth/utilities/buildUnauthorizedRedirect.js +28 -0
- package/dist/oauth/utilities/clearCookie.d.ts +0 -1
- package/dist/oauth/utilities/clearCookie.js +5 -3
- package/dist/oauth/utilities/createCookieOptions.d.ts +0 -1
- package/dist/oauth/utilities/createCookieOptions.js +9 -4
- package/dist/oauth/utilities/createDebugLogger.d.ts +0 -1
- package/dist/oauth/utilities/createDebugLogger.js +0 -2
- package/dist/oauth/utilities/establishSession.d.ts +22 -0
- package/dist/oauth/utilities/establishSession.js +80 -0
- package/dist/oauth/utilities/exchangeCodeForAccessToken.d.ts +23 -0
- package/dist/oauth/utilities/exchangeCodeForAccessToken.js +26 -0
- package/dist/oauth/utilities/extractOrigin.d.ts +0 -1
- package/dist/oauth/utilities/extractOrigin.js +0 -2
- package/dist/oauth/utilities/figmaHostnames.d.ts +2 -0
- package/dist/oauth/utilities/figmaHostnames.js +24 -0
- package/dist/oauth/utilities/getAdminCollectionSlug.d.ts +0 -1
- package/dist/oauth/utilities/getAdminCollectionSlug.js +0 -2
- package/dist/oauth/utilities/getAuthorizeURL.d.ts +65 -2
- package/dist/oauth/utilities/getAuthorizeURL.js +57 -4
- package/dist/oauth/utilities/getCookieExpiration.d.ts +0 -1
- package/dist/oauth/utilities/getCookieExpiration.js +0 -2
- package/dist/oauth/utilities/getSecondsFromTokenExp.d.ts +0 -1
- package/dist/oauth/utilities/getSecondsFromTokenExp.js +0 -2
- package/dist/oauth/utilities/getTokenExp.d.ts +0 -1
- package/dist/oauth/utilities/getTokenExp.js +0 -2
- package/dist/oauth/utilities/getUsernameField.d.ts +0 -1
- package/dist/oauth/utilities/getUsernameField.js +0 -2
- package/dist/oauth/utilities/hasUserTokenPropsChanged.d.ts +0 -1
- package/dist/oauth/utilities/hasUserTokenPropsChanged.js +0 -2
- package/dist/oauth/utilities/isAbsoluteURL.d.ts +1 -0
- package/dist/oauth/utilities/isAbsoluteURL.js +1 -0
- package/dist/oauth/utilities/isDuplicateKeyError.d.ts +6 -0
- package/dist/oauth/utilities/isDuplicateKeyError.js +12 -0
- package/dist/oauth/utilities/mergeHeaders.d.ts +0 -1
- package/dist/oauth/utilities/mergeHeaders.js +0 -2
- package/dist/oauth/utilities/refreshTokens.d.ts +0 -1
- package/dist/oauth/utilities/refreshTokens.js +21 -13
- package/dist/oauth/utilities/withPartitionedCookie.d.ts +19 -0
- package/dist/oauth/utilities/withPartitionedCookie.js +26 -0
- package/dist/oauth/utils/getSearchParam.d.ts +17 -0
- package/dist/oauth/utils/getSearchParam.js +22 -0
- package/dist/plugin/adapter.d.ts +0 -1
- package/dist/plugin/adapter.js +0 -2
- package/dist/plugin/auth-preflight.d.ts +7 -0
- package/dist/plugin/auth-preflight.js +18 -0
- package/dist/plugin/bootstrap-preflight.d.ts +22 -0
- package/dist/plugin/bootstrap-preflight.js +43 -0
- package/dist/plugin/build-config.d.ts +27 -15
- package/dist/plugin/build-config.js +380 -16
- package/dist/plugin/dev-cookie-names.d.ts +13 -0
- package/dist/plugin/dev-cookie-names.js +17 -0
- package/dist/scss.d.js +2 -0
- package/dist/storage-content-api/api-types.d.ts +183 -0
- package/dist/storage-content-api/api-types.js +4 -0
- package/dist/storage-content-api/client-uploads/generate.d.ts +14 -0
- package/dist/storage-content-api/client-uploads/generate.js +69 -0
- package/dist/storage-content-api/client.d.ts +5 -0
- package/dist/storage-content-api/client.js +37 -0
- package/dist/storage-content-api/generateURL.d.ts +6 -0
- package/dist/storage-content-api/generateURL.js +6 -0
- package/dist/storage-content-api/handleDelete.d.ts +7 -0
- package/dist/storage-content-api/handleDelete.js +15 -0
- package/dist/storage-content-api/handleUpload.d.ts +10 -0
- package/dist/storage-content-api/handleUpload.js +162 -0
- package/dist/storage-content-api/index.d.ts +4 -0
- package/dist/storage-content-api/index.js +37 -0
- package/dist/storage-content-api/staticHandler.d.ts +9 -0
- package/dist/storage-content-api/staticHandler.js +61 -0
- package/dist/storage-content-api/types.d.ts +9 -0
- package/dist/storage-content-api/types.js +1 -0
- package/dist/storage-content-api/utilities/getSafeFilename.d.ts +11 -0
- package/dist/storage-content-api/utilities/getSafeFilename.js +59 -0
- package/dist/storage-content-api/utilities/index.d.ts +2 -0
- package/dist/storage-content-api/utilities/index.js +2 -0
- package/dist/storage-content-api/utilities/parseUploadReference.d.ts +17 -0
- package/dist/storage-content-api/utilities/parseUploadReference.js +27 -0
- package/dist/templates/.env.example +5 -0
- package/dist/templates/README.md +19 -0
- package/dist/types/config.d.ts +2 -2
- package/dist/types/config.js +0 -4
- package/dist/types.d.ts +10 -2
- package/dist/types.js +0 -2
- package/dist/utils/adapters/nextjs.d.ts +8 -0
- package/dist/utils/adapters/nextjs.js +61 -0
- package/dist/utils/adapters/nitro.d.ts +8 -0
- package/dist/utils/adapters/nitro.js +172 -0
- package/dist/utils/adapters/vite.d.ts +9 -0
- package/dist/utils/adapters/vite.js +31 -0
- package/dist/utils/asset-collection.d.ts +27 -7
- package/dist/utils/asset-collection.js +59 -32
- package/dist/utils/build-detection.d.ts +5 -12
- package/dist/utils/build-detection.js +74 -13
- package/dist/utils/build-lambda-zip.d.ts +25 -0
- package/dist/utils/build-lambda-zip.js +90 -0
- package/dist/utils/cache-bootstrap.d.ts +7 -0
- package/dist/utils/cache-bootstrap.js +16 -0
- package/dist/utils/config.d.ts +0 -1
- package/dist/utils/config.js +1 -3
- package/dist/utils/deploy-adapter.d.ts +45 -0
- package/dist/utils/deploy-adapter.js +56 -0
- package/dist/utils/download-template.d.ts +9 -2
- package/dist/utils/download-template.js +24 -20
- package/dist/utils/env-management.d.ts +24 -8
- package/dist/utils/env-management.js +119 -66
- package/dist/utils/format-env-suffix.d.ts +11 -0
- package/dist/utils/format-env-suffix.js +11 -0
- package/dist/utils/format.d.ts +0 -1
- package/dist/utils/format.js +0 -2
- package/dist/utils/formatter.d.ts +0 -1
- package/dist/utils/formatter.js +23 -13
- package/dist/utils/fs-utils.d.ts +12 -0
- package/dist/utils/fs-utils.js +55 -0
- package/dist/utils/git.d.ts +0 -1
- package/dist/utils/git.js +0 -2
- package/dist/utils/handle-upgrade.d.ts +8 -0
- package/dist/utils/handle-upgrade.js +39 -0
- package/dist/utils/is-debug.d.ts +0 -1
- package/dist/utils/is-debug.js +0 -2
- package/dist/utils/lambda-config.d.ts +3 -2
- package/dist/utils/lambda-config.js +75 -80
- package/dist/utils/load-payload-config.d.ts +9 -0
- package/dist/utils/load-payload-config.js +27 -0
- package/dist/utils/log.d.ts +0 -1
- package/dist/utils/log.js +0 -2
- package/dist/utils/messages.d.ts +1 -3
- package/dist/utils/messages.js +47 -13
- package/dist/utils/package-manager.d.ts +24 -1
- package/dist/utils/package-manager.js +53 -2
- package/dist/utils/parse-template-spec.d.ts +11 -0
- package/dist/utils/parse-template-spec.js +60 -0
- package/dist/utils/payload-config-ast.d.ts +27 -7
- package/dist/utils/payload-config-ast.js +106 -60
- package/dist/utils/payload-config-finder.d.ts +2 -3
- package/dist/utils/payload-config-finder.js +48 -11
- package/dist/utils/payload-config-modifier.d.ts +1 -2
- package/dist/utils/payload-config-modifier.js +114 -68
- package/dist/utils/payload-package-check.d.ts +28 -3
- package/dist/utils/payload-package-check.js +90 -31
- package/dist/utils/project.d.ts +8 -4
- package/dist/utils/project.js +63 -37
- package/dist/utils/resolve-environment.d.ts +13 -0
- package/dist/utils/resolve-environment.js +29 -0
- package/dist/utils/s3-upload.d.ts +7 -3
- package/dist/utils/s3-upload.js +44 -9
- package/dist/utils/token-display.d.ts +5 -2
- package/dist/utils/token-display.js +49 -24
- package/dist/utils/typescript-validator.d.ts +0 -1
- package/dist/utils/typescript-validator.js +4 -8
- package/dist/utils/version-check.d.ts +2 -0
- package/dist/utils/version-check.js +43 -0
- package/package.json +47 -16
- package/dist/api/control-plane.d.ts.map +0 -1
- package/dist/api/control-plane.js.map +0 -1
- package/dist/api/figma-api.d.ts.map +0 -1
- package/dist/api/figma-api.js.map +0 -1
- package/dist/auth/browser.d.ts.map +0 -1
- package/dist/auth/browser.js.map +0 -1
- package/dist/auth/callback-server.d.ts.map +0 -1
- package/dist/auth/callback-server.js.map +0 -1
- package/dist/auth/crypto-utils.d.ts.map +0 -1
- package/dist/auth/crypto-utils.js.map +0 -1
- package/dist/auth/jwt-validator.d.ts.map +0 -1
- package/dist/auth/jwt-validator.js.map +0 -1
- package/dist/auth/oauth-flow.d.ts.map +0 -1
- package/dist/auth/oauth-flow.js.map +0 -1
- package/dist/auth/pkce.d.ts.map +0 -1
- package/dist/auth/pkce.js.map +0 -1
- package/dist/auth/project-token.d.ts.map +0 -1
- package/dist/auth/project-token.js.map +0 -1
- package/dist/auth/refresh.d.ts.map +0 -1
- package/dist/auth/refresh.js.map +0 -1
- package/dist/auth/token-store.d.ts.map +0 -1
- package/dist/auth/token-store.js.map +0 -1
- package/dist/auth/types.d.ts.map +0 -1
- package/dist/auth/types.js.map +0 -1
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/commands/deploy.d.ts.map +0 -1
- package/dist/commands/deploy.js.map +0 -1
- package/dist/commands/init.d.ts.map +0 -1
- package/dist/commands/init.js.map +0 -1
- package/dist/commands/list-tokens.d.ts.map +0 -1
- package/dist/commands/list-tokens.js.map +0 -1
- package/dist/commands/login.d.ts.map +0 -1
- package/dist/commands/login.js.map +0 -1
- package/dist/commands/logout.d.ts.map +0 -1
- package/dist/commands/logout.js.map +0 -1
- package/dist/config/oauth.d.ts.map +0 -1
- package/dist/config/oauth.js.map +0 -1
- package/dist/constants.d.ts.map +0 -1
- package/dist/constants.js.map +0 -1
- package/dist/exports/client.d.ts.map +0 -1
- package/dist/exports/client.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/oauth/components/LoginButton/index.d.ts.map +0 -1
- package/dist/oauth/components/LoginButton/index.js.map +0 -1
- package/dist/oauth/components/LogoutButton/index.d.ts.map +0 -1
- package/dist/oauth/components/LogoutButton/index.js.map +0 -1
- package/dist/oauth/defaults.d.ts.map +0 -1
- package/dist/oauth/defaults.js.map +0 -1
- package/dist/oauth/endpoints/getLoginEndpoint.d.ts.map +0 -1
- package/dist/oauth/endpoints/getLoginEndpoint.js.map +0 -1
- package/dist/oauth/endpoints/getLogoutEndpoint.d.ts.map +0 -1
- package/dist/oauth/endpoints/getLogoutEndpoint.js.map +0 -1
- package/dist/oauth/endpoints/getMetaEndpoint.d.ts.map +0 -1
- package/dist/oauth/endpoints/getMetaEndpoint.js.map +0 -1
- package/dist/oauth/endpoints/getRedirectToLoginEndpoint.d.ts.map +0 -1
- package/dist/oauth/endpoints/getRedirectToLoginEndpoint.js.map +0 -1
- package/dist/oauth/exports/client.d.ts.map +0 -1
- package/dist/oauth/exports/client.js.map +0 -1
- package/dist/oauth/hooks/afterLogout.d.ts.map +0 -1
- package/dist/oauth/hooks/afterLogout.js.map +0 -1
- package/dist/oauth/hooks/me.d.ts.map +0 -1
- package/dist/oauth/hooks/me.js.map +0 -1
- package/dist/oauth/hooks/refresh.d.ts.map +0 -1
- package/dist/oauth/hooks/refresh.js.map +0 -1
- package/dist/oauth/index.d.ts.map +0 -1
- package/dist/oauth/index.js.map +0 -1
- package/dist/oauth/strategy/index.d.ts.map +0 -1
- package/dist/oauth/strategy/index.js.map +0 -1
- package/dist/oauth/types.d.ts.map +0 -1
- package/dist/oauth/types.js.map +0 -1
- package/dist/oauth/utilities/clearCookie.d.ts.map +0 -1
- package/dist/oauth/utilities/clearCookie.js.map +0 -1
- package/dist/oauth/utilities/createCookieOptions.d.ts.map +0 -1
- package/dist/oauth/utilities/createCookieOptions.js.map +0 -1
- package/dist/oauth/utilities/createDebugLogger.d.ts.map +0 -1
- package/dist/oauth/utilities/createDebugLogger.js.map +0 -1
- package/dist/oauth/utilities/extractOrigin.d.ts.map +0 -1
- package/dist/oauth/utilities/extractOrigin.js.map +0 -1
- package/dist/oauth/utilities/getAdminCollectionSlug.d.ts.map +0 -1
- package/dist/oauth/utilities/getAdminCollectionSlug.js.map +0 -1
- package/dist/oauth/utilities/getAdminPath.d.ts +0 -8
- package/dist/oauth/utilities/getAdminPath.d.ts.map +0 -1
- package/dist/oauth/utilities/getAdminPath.js +0 -9
- package/dist/oauth/utilities/getAdminPath.js.map +0 -1
- package/dist/oauth/utilities/getAuthorizeURL.d.ts.map +0 -1
- package/dist/oauth/utilities/getAuthorizeURL.js.map +0 -1
- package/dist/oauth/utilities/getCookieExpiration.d.ts.map +0 -1
- package/dist/oauth/utilities/getCookieExpiration.js.map +0 -1
- package/dist/oauth/utilities/getSecondsFromTokenExp.d.ts.map +0 -1
- package/dist/oauth/utilities/getSecondsFromTokenExp.js.map +0 -1
- package/dist/oauth/utilities/getTokenExp.d.ts.map +0 -1
- package/dist/oauth/utilities/getTokenExp.js.map +0 -1
- package/dist/oauth/utilities/getUsernameField.d.ts.map +0 -1
- package/dist/oauth/utilities/getUsernameField.js.map +0 -1
- package/dist/oauth/utilities/hasUserTokenPropsChanged.d.ts.map +0 -1
- package/dist/oauth/utilities/hasUserTokenPropsChanged.js.map +0 -1
- package/dist/oauth/utilities/mergeHeaders.d.ts.map +0 -1
- package/dist/oauth/utilities/mergeHeaders.js.map +0 -1
- package/dist/oauth/utilities/refreshTokens.d.ts.map +0 -1
- package/dist/oauth/utilities/refreshTokens.js.map +0 -1
- package/dist/plugin/adapter.d.ts.map +0 -1
- package/dist/plugin/adapter.js.map +0 -1
- package/dist/plugin/build-config.d.ts.map +0 -1
- package/dist/plugin/build-config.js.map +0 -1
- package/dist/types/config.d.ts.map +0 -1
- package/dist/types/config.js.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/utils/asset-collection.d.ts.map +0 -1
- package/dist/utils/asset-collection.js.map +0 -1
- package/dist/utils/build-detection.d.ts.map +0 -1
- package/dist/utils/build-detection.js.map +0 -1
- package/dist/utils/config.d.ts.map +0 -1
- package/dist/utils/config.js.map +0 -1
- package/dist/utils/download-template.d.ts.map +0 -1
- package/dist/utils/download-template.js.map +0 -1
- package/dist/utils/env-management.d.ts.map +0 -1
- package/dist/utils/env-management.js.map +0 -1
- package/dist/utils/format.d.ts.map +0 -1
- package/dist/utils/format.js.map +0 -1
- package/dist/utils/formatter.d.ts.map +0 -1
- package/dist/utils/formatter.js.map +0 -1
- package/dist/utils/git.d.ts.map +0 -1
- package/dist/utils/git.js.map +0 -1
- package/dist/utils/is-debug.d.ts.map +0 -1
- package/dist/utils/is-debug.js.map +0 -1
- package/dist/utils/lambda-config.d.ts.map +0 -1
- package/dist/utils/lambda-config.js.map +0 -1
- package/dist/utils/log.d.ts.map +0 -1
- package/dist/utils/log.js.map +0 -1
- package/dist/utils/messages.d.ts.map +0 -1
- package/dist/utils/messages.js.map +0 -1
- package/dist/utils/package-manager.d.ts.map +0 -1
- package/dist/utils/package-manager.js.map +0 -1
- package/dist/utils/payload-config-ast.d.ts.map +0 -1
- package/dist/utils/payload-config-ast.js.map +0 -1
- package/dist/utils/payload-config-finder.d.ts.map +0 -1
- package/dist/utils/payload-config-finder.js.map +0 -1
- package/dist/utils/payload-config-modifier.d.ts.map +0 -1
- package/dist/utils/payload-config-modifier.js.map +0 -1
- package/dist/utils/payload-package-check.d.ts.map +0 -1
- package/dist/utils/payload-package-check.js.map +0 -1
- package/dist/utils/project.d.ts.map +0 -1
- package/dist/utils/project.js.map +0 -1
- package/dist/utils/s3-upload.d.ts.map +0 -1
- package/dist/utils/s3-upload.js.map +0 -1
- package/dist/utils/token-display.d.ts.map +0 -1
- package/dist/utils/token-display.js.map +0 -1
- package/dist/utils/typescript-validator.d.ts.map +0 -1
- package/dist/utils/typescript-validator.js.map +0 -1
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* TODO: Replace with real API calls when Control Plane is available
|
|
5
5
|
*/
|
|
6
|
+
import type { AuthCredential } from '../auth/credentials.js';
|
|
6
7
|
import type { Tenant } from '../types/config.js';
|
|
7
8
|
/**
|
|
8
9
|
* Error thrown when Control Plane API calls fail
|
|
@@ -27,6 +28,14 @@ export interface CreateTenantOptions {
|
|
|
27
28
|
* Options for creating a new deployment
|
|
28
29
|
*/
|
|
29
30
|
export interface CreateDeploymentOptions {
|
|
31
|
+
/** Framework adapter name (e.g., "vite", "nextjs"). Forwarded to Gatekeeper. */
|
|
32
|
+
adapter?: string;
|
|
33
|
+
/** SPA fallback path (e.g., "/index.html"). Vite-only. */
|
|
34
|
+
fallback?: string;
|
|
35
|
+
/** Pages keyed by route, each with its associated asset keys */
|
|
36
|
+
pages: Record<string, {
|
|
37
|
+
assets: string[];
|
|
38
|
+
}>;
|
|
30
39
|
/** List of static asset paths that need upload URLs */
|
|
31
40
|
staticAssets: string[];
|
|
32
41
|
}
|
|
@@ -38,14 +47,17 @@ export interface CreateDeploymentResponse {
|
|
|
38
47
|
codeUploadUrl: string;
|
|
39
48
|
/** Unique deployment ID */
|
|
40
49
|
deploymentId: string;
|
|
50
|
+
/** Map of page asset paths to their signed S3 upload URLs */
|
|
51
|
+
pageUploadUrls: Record<string, string>;
|
|
41
52
|
/** Map of static asset paths to their signed S3 upload URLs */
|
|
42
53
|
staticAssetUploadUrls: Record<string, string>;
|
|
43
54
|
}
|
|
44
55
|
export interface CreateDeploymentApiResponse {
|
|
45
56
|
error: boolean;
|
|
46
57
|
meta: {
|
|
47
|
-
code_upload_url: string;
|
|
48
58
|
deployment_id: string;
|
|
59
|
+
lambda_zip_upload_url: string;
|
|
60
|
+
page_upload_urls: Record<string, string>;
|
|
49
61
|
static_asset_upload_urls: Record<string, string>;
|
|
50
62
|
};
|
|
51
63
|
status: number;
|
|
@@ -65,6 +77,8 @@ export interface PerformDeploymentResponse {
|
|
|
65
77
|
deploymentId: string;
|
|
66
78
|
/** Status message */
|
|
67
79
|
message: string;
|
|
80
|
+
/** List of tenant domains */
|
|
81
|
+
tenantDomains: string[];
|
|
68
82
|
}
|
|
69
83
|
export interface PerformDeploymentApiResponse {
|
|
70
84
|
error: boolean;
|
|
@@ -72,6 +86,7 @@ export interface PerformDeploymentApiResponse {
|
|
|
72
86
|
deployment_id: string;
|
|
73
87
|
message: string;
|
|
74
88
|
status: string;
|
|
89
|
+
tenant_domains: string[];
|
|
75
90
|
};
|
|
76
91
|
status: number;
|
|
77
92
|
}
|
|
@@ -82,7 +97,7 @@ export interface PerformDeploymentApiResponse {
|
|
|
82
97
|
* @param accessToken - OAuth access token
|
|
83
98
|
* @returns Array of tenant instances
|
|
84
99
|
*/
|
|
85
|
-
export declare function listTenants(
|
|
100
|
+
export declare function listTenants(credential: AuthCredential): Promise<Tenant[]>;
|
|
86
101
|
/**
|
|
87
102
|
* Create a new tenant instance
|
|
88
103
|
* Maps to: POST /v1/tenant
|
|
@@ -91,7 +106,7 @@ export declare function listTenants(accessToken: string): Promise<Tenant[]>;
|
|
|
91
106
|
* @param options - Tenant creation options
|
|
92
107
|
* @returns Newly created tenant
|
|
93
108
|
*/
|
|
94
|
-
export declare function createTenant(
|
|
109
|
+
export declare function createTenant(credential: AuthCredential, options: CreateTenantOptions): Promise<Tenant>;
|
|
95
110
|
/**
|
|
96
111
|
* Get details for a specific tenant
|
|
97
112
|
* Maps to: GET /v1/tenant/{tenant_id}
|
|
@@ -100,7 +115,7 @@ export declare function createTenant(accessToken: string, options: CreateTenantO
|
|
|
100
115
|
* @param tenantId - Tenant ID
|
|
101
116
|
* @returns Tenant details
|
|
102
117
|
*/
|
|
103
|
-
export declare function getTenantDetails(
|
|
118
|
+
export declare function getTenantDetails(credential: AuthCredential, tenantId: string): Promise<Tenant>;
|
|
104
119
|
/**
|
|
105
120
|
* Create a new deployment and get signed upload URLs
|
|
106
121
|
* Maps to: POST /v1/tenant/{tenant_id}/deploy/create
|
|
@@ -110,7 +125,7 @@ export declare function getTenantDetails(accessToken: string, tenantId: string):
|
|
|
110
125
|
* @param options - Deployment creation options
|
|
111
126
|
* @returns Deployment ID and upload URLs
|
|
112
127
|
*/
|
|
113
|
-
export declare function createDeployment(
|
|
128
|
+
export declare function createDeployment(credential: AuthCredential, tenantId: string, options: CreateDeploymentOptions): Promise<CreateDeploymentResponse>;
|
|
114
129
|
/**
|
|
115
130
|
* Perform deployment for a created deployment ID
|
|
116
131
|
* Maps to: POST /v1/tenant/{tenant_id}/deploy/perform
|
|
@@ -120,5 +135,39 @@ export declare function createDeployment(accessToken: string, tenantId: string,
|
|
|
120
135
|
* @param options - Deployment perform options
|
|
121
136
|
* @returns Deployment status and message
|
|
122
137
|
*/
|
|
123
|
-
export declare function performDeployment(
|
|
124
|
-
|
|
138
|
+
export declare function performDeployment(credential: AuthCredential, tenantId: string, options: PerformDeploymentOptions): Promise<PerformDeploymentResponse>;
|
|
139
|
+
/**
|
|
140
|
+
* A single environment returned by the bootstrap endpoint
|
|
141
|
+
*/
|
|
142
|
+
export type BootstrapEnvironment = {
|
|
143
|
+
contentSystemId: string;
|
|
144
|
+
name: string;
|
|
145
|
+
tenantInstanceId: string;
|
|
146
|
+
};
|
|
147
|
+
/**
|
|
148
|
+
* Response from the bootstrap endpoint (camelCased)
|
|
149
|
+
*/
|
|
150
|
+
export type BootstrapInfo = {
|
|
151
|
+
environments: BootstrapEnvironment[];
|
|
152
|
+
oauthCredentials: {
|
|
153
|
+
oauthClientId: string;
|
|
154
|
+
oauthClientSecret: string;
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
/**
|
|
158
|
+
* Get bootstrap info for a CMS resource
|
|
159
|
+
* Maps to: GET /v1/cms/:cmsResourceId/bootstrap
|
|
160
|
+
*
|
|
161
|
+
* @param accessToken - OAuth access token
|
|
162
|
+
* @param cmsResourceId - CMS Resource ID (project ID)
|
|
163
|
+
* @param environmentName - Optional environment name filter
|
|
164
|
+
*/
|
|
165
|
+
export declare function getBootstrapInfo(credential: AuthCredential, cmsResourceId: string, environmentName?: string): Promise<BootstrapInfo>;
|
|
166
|
+
/**
|
|
167
|
+
* Resolve a CMS Resource ID from a legacy dataset (content system) ID.
|
|
168
|
+
* Maps to: GET /v1/cms/dataset/:datasetId
|
|
169
|
+
*
|
|
170
|
+
* Used during upgrade migration to convert old FIGMA_CONTENT_API_CONTENT_SYSTEM_ID
|
|
171
|
+
* into the new FIGMA_PROJECT_ID (CMS Resource ID).
|
|
172
|
+
*/
|
|
173
|
+
export declare function getCmsResourceId(credential: AuthCredential, datasetId: string): Promise<string>;
|
|
@@ -2,18 +2,14 @@
|
|
|
2
2
|
* Control Plane API Client
|
|
3
3
|
*
|
|
4
4
|
* TODO: Replace with real API calls when Control Plane is available
|
|
5
|
-
*/ import {
|
|
5
|
+
*/ import { getAuthHeaders } from '../auth/credentials.js';
|
|
6
|
+
import { getEnvConfig } from '../constants.js';
|
|
6
7
|
import * as log from '../utils/log.js';
|
|
7
|
-
|
|
8
|
-
* Control Plane API base URLs
|
|
9
|
-
*/ const CONTROL_PLANE_API_URLS = {
|
|
10
|
-
production: 'https://api.figma.com',
|
|
11
|
-
staging: 'https://api.staging.figma.com'
|
|
12
|
-
};
|
|
8
|
+
import { parseControlPlaneApiError } from './error-response.js';
|
|
13
9
|
/**
|
|
14
10
|
* Get the Control Plane API base URL based on environment
|
|
15
11
|
*/ function getControlPlaneBaseUrl() {
|
|
16
|
-
return
|
|
12
|
+
return getEnvConfig().apiBaseUrl;
|
|
17
13
|
}
|
|
18
14
|
/**
|
|
19
15
|
* Error thrown when Control Plane API calls fail
|
|
@@ -31,10 +27,8 @@ import * as log from '../utils/log.js';
|
|
|
31
27
|
*
|
|
32
28
|
* @param accessToken - OAuth access token
|
|
33
29
|
* @returns Array of tenant instances
|
|
34
|
-
*/ export async function listTenants(
|
|
35
|
-
|
|
36
|
-
// Default to true until real API is available
|
|
37
|
-
const shouldMock = process.env.FIGMA_MOCK_CONTROL_PLANE !== 'false';
|
|
30
|
+
*/ export async function listTenants(credential) {
|
|
31
|
+
const shouldMock = process.env.FIGMA_MOCK_CONTROL_PLANE === 'true';
|
|
38
32
|
if (shouldMock) {
|
|
39
33
|
// MOCK IMPLEMENTATION: Return sample tenants for testing
|
|
40
34
|
log.debug('Using mock Control Plane API for listTenants (FIGMA_MOCK_CONTROL_PLANE != "false")');
|
|
@@ -58,14 +52,13 @@ import * as log from '../utils/log.js';
|
|
|
58
52
|
];
|
|
59
53
|
}
|
|
60
54
|
// REAL API IMPLEMENTATION
|
|
61
|
-
const response = await
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
55
|
+
const response = await controlPlaneFetch({
|
|
56
|
+
context: 'list tenants',
|
|
57
|
+
options: {
|
|
58
|
+
headers: getAuthHeaders(credential)
|
|
59
|
+
},
|
|
60
|
+
url: `${getControlPlaneBaseUrl()}/v1/tenant`
|
|
65
61
|
});
|
|
66
|
-
if (!response.ok) {
|
|
67
|
-
throw new ControlPlaneError(`Failed to list tenants: ${response.status} ${response.statusText}`, response.status);
|
|
68
|
-
}
|
|
69
62
|
return response.json();
|
|
70
63
|
}
|
|
71
64
|
/**
|
|
@@ -75,9 +68,9 @@ import * as log from '../utils/log.js';
|
|
|
75
68
|
* @param accessToken - OAuth access token
|
|
76
69
|
* @param options - Tenant creation options
|
|
77
70
|
* @returns Newly created tenant
|
|
78
|
-
*/ export async function createTenant(
|
|
71
|
+
*/ export async function createTenant(credential, options) {
|
|
79
72
|
// Check if control plane API should be mocked
|
|
80
|
-
const shouldMock = process.env.FIGMA_MOCK_CONTROL_PLANE
|
|
73
|
+
const shouldMock = process.env.FIGMA_MOCK_CONTROL_PLANE === 'true';
|
|
81
74
|
if (shouldMock) {
|
|
82
75
|
// MOCK IMPLEMENTATION: Generate mock tenant for testing
|
|
83
76
|
log.debug('Using mock Control Plane API for createTenant (FIGMA_MOCK_CONTROL_PLANE != "false")');
|
|
@@ -94,19 +87,20 @@ import * as log from '../utils/log.js';
|
|
|
94
87
|
};
|
|
95
88
|
}
|
|
96
89
|
// REAL API IMPLEMENTATION
|
|
97
|
-
const response = await
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
90
|
+
const response = await controlPlaneFetch({
|
|
91
|
+
context: 'create tenant',
|
|
92
|
+
options: {
|
|
93
|
+
body: JSON.stringify({
|
|
94
|
+
name: options.name
|
|
95
|
+
}),
|
|
96
|
+
headers: {
|
|
97
|
+
...getAuthHeaders(credential),
|
|
98
|
+
'Content-Type': 'application/json'
|
|
99
|
+
},
|
|
100
|
+
method: 'POST'
|
|
104
101
|
},
|
|
105
|
-
|
|
102
|
+
url: `${getControlPlaneBaseUrl()}/v1/tenant`
|
|
106
103
|
});
|
|
107
|
-
if (!response.ok) {
|
|
108
|
-
throw new ControlPlaneError(`Failed to create tenant: ${response.status} ${response.statusText}`, response.status);
|
|
109
|
-
}
|
|
110
104
|
return response.json();
|
|
111
105
|
}
|
|
112
106
|
/**
|
|
@@ -116,9 +110,9 @@ import * as log from '../utils/log.js';
|
|
|
116
110
|
* @param accessToken - OAuth access token
|
|
117
111
|
* @param tenantId - Tenant ID
|
|
118
112
|
* @returns Tenant details
|
|
119
|
-
*/ export async function getTenantDetails(
|
|
113
|
+
*/ export async function getTenantDetails(credential, tenantId) {
|
|
120
114
|
// Check if control plane API should be mocked
|
|
121
|
-
const shouldMock = process.env.FIGMA_MOCK_CONTROL_PLANE
|
|
115
|
+
const shouldMock = process.env.FIGMA_MOCK_CONTROL_PLANE === 'true';
|
|
122
116
|
if (shouldMock) {
|
|
123
117
|
// MOCK IMPLEMENTATION: Return mock tenant details for testing
|
|
124
118
|
log.debug('Using mock Control Plane API for getTenantDetails (FIGMA_MOCK_CONTROL_PLANE != "false")');
|
|
@@ -132,14 +126,13 @@ import * as log from '../utils/log.js';
|
|
|
132
126
|
};
|
|
133
127
|
}
|
|
134
128
|
// REAL API IMPLEMENTATION
|
|
135
|
-
const response = await
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
129
|
+
const response = await controlPlaneFetch({
|
|
130
|
+
context: 'get tenant details',
|
|
131
|
+
options: {
|
|
132
|
+
headers: getAuthHeaders(credential)
|
|
133
|
+
},
|
|
134
|
+
url: `${getControlPlaneBaseUrl()}/v1/tenant/${tenantId}`
|
|
139
135
|
});
|
|
140
|
-
if (!response.ok) {
|
|
141
|
-
throw new ControlPlaneError(`Failed to get tenant details: ${response.status} ${response.statusText}`, response.status);
|
|
142
|
-
}
|
|
143
136
|
return response.json();
|
|
144
137
|
}
|
|
145
138
|
/**
|
|
@@ -150,12 +143,12 @@ import * as log from '../utils/log.js';
|
|
|
150
143
|
* @param tenantId - Tenant ID
|
|
151
144
|
* @param options - Deployment creation options
|
|
152
145
|
* @returns Deployment ID and upload URLs
|
|
153
|
-
*/ export async function createDeployment(
|
|
146
|
+
*/ export async function createDeployment(credential, tenantId, options) {
|
|
154
147
|
// Check if control plane API should be mocked
|
|
155
|
-
const shouldMock = process.env.FIGMA_MOCK_CONTROL_PLANE
|
|
148
|
+
const shouldMock = process.env.FIGMA_MOCK_CONTROL_PLANE === 'true';
|
|
156
149
|
if (shouldMock) {
|
|
157
150
|
// MOCK IMPLEMENTATION: Generate mock deployment and signed URLs
|
|
158
|
-
log.debug('Using mock Control Plane API for createDeployment (FIGMA_MOCK_CONTROL_PLANE
|
|
151
|
+
log.debug('Using mock Control Plane API for createDeployment (FIGMA_MOCK_CONTROL_PLANE === "true")');
|
|
159
152
|
const deploymentId = `deploy_${Math.random().toString(36).substring(2, 11)}`;
|
|
160
153
|
const mockBucket = 'figma-cms-deployments-mock';
|
|
161
154
|
const mockRegion = 'us-west-2';
|
|
@@ -166,33 +159,61 @@ import * as log from '../utils/log.js';
|
|
|
166
159
|
const encodedPath = encodeURIComponent(assetPath);
|
|
167
160
|
staticAssetUploadUrls[assetPath] = `${mockBaseUrl}/${tenantId}/${deploymentId}/static/${encodedPath}?X-Amz-Signature=mock`;
|
|
168
161
|
}
|
|
162
|
+
// Generate mock signed URLs for page assets
|
|
163
|
+
const pageUploadUrls = {};
|
|
164
|
+
for (const pageData of Object.values(options.pages)){
|
|
165
|
+
for (const assetPath of pageData.assets){
|
|
166
|
+
const encodedPath = encodeURIComponent(assetPath);
|
|
167
|
+
pageUploadUrls[assetPath] = `${mockBaseUrl}/${tenantId}/${deploymentId}/pages/${encodedPath}?X-Amz-Signature=mock`;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
169
170
|
// Generate mock signed URL for code zip
|
|
170
171
|
const codeUploadUrl = `${mockBaseUrl}/${tenantId}/${deploymentId}/lambda.zip?X-Amz-Signature=mock`;
|
|
171
172
|
return {
|
|
172
173
|
codeUploadUrl,
|
|
173
174
|
deploymentId,
|
|
175
|
+
pageUploadUrls,
|
|
174
176
|
staticAssetUploadUrls
|
|
175
177
|
};
|
|
176
178
|
}
|
|
179
|
+
const url = `${getControlPlaneBaseUrl()}/v1/cms/tenant/${tenantId}/deploy/create`;
|
|
180
|
+
log.debug(`Calling createDeployment API at ${url}`);
|
|
181
|
+
// Build pages payload: { route: { assets: [...] } }
|
|
182
|
+
const pages = {};
|
|
183
|
+
for (const [route, pageData] of Object.entries(options.pages)){
|
|
184
|
+
pages[route] = {
|
|
185
|
+
assets: pageData.assets
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
const body = {
|
|
189
|
+
pages,
|
|
190
|
+
static_assets: options.staticAssets
|
|
191
|
+
};
|
|
192
|
+
if (options.adapter) {
|
|
193
|
+
body.adapter = options.adapter;
|
|
194
|
+
}
|
|
195
|
+
if (options.fallback) {
|
|
196
|
+
body.fallback = options.fallback;
|
|
197
|
+
}
|
|
177
198
|
// REAL API IMPLEMENTATION
|
|
178
|
-
const response = await
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
199
|
+
const response = await controlPlaneFetch({
|
|
200
|
+
context: 'create deployment',
|
|
201
|
+
options: {
|
|
202
|
+
body: JSON.stringify(body),
|
|
203
|
+
headers: {
|
|
204
|
+
...getAuthHeaders(credential),
|
|
205
|
+
'Content-Type': 'application/json'
|
|
206
|
+
},
|
|
207
|
+
method: 'POST'
|
|
185
208
|
},
|
|
186
|
-
|
|
209
|
+
url
|
|
187
210
|
});
|
|
188
|
-
if (!response.ok) {
|
|
189
|
-
throw new ControlPlaneError(`Failed to create deployment: ${response.status} ${response.statusText}`, response.status);
|
|
190
|
-
}
|
|
191
211
|
const data = await response.json();
|
|
192
212
|
// Map API response format to our interface
|
|
193
213
|
return {
|
|
194
|
-
codeUploadUrl: data.meta.
|
|
214
|
+
codeUploadUrl: data.meta.lambda_zip_upload_url,
|
|
195
215
|
deploymentId: data.meta.deployment_id,
|
|
216
|
+
pageUploadUrls: data.meta.page_upload_urls,
|
|
196
217
|
staticAssetUploadUrls: data.meta.static_asset_upload_urls
|
|
197
218
|
};
|
|
198
219
|
}
|
|
@@ -204,37 +225,130 @@ import * as log from '../utils/log.js';
|
|
|
204
225
|
* @param tenantId - Tenant ID
|
|
205
226
|
* @param options - Deployment perform options
|
|
206
227
|
* @returns Deployment status and message
|
|
207
|
-
*/ export async function performDeployment(
|
|
208
|
-
|
|
209
|
-
const shouldMock = process.env.FIGMA_MOCK_CONTROL_PLANE !== 'false';
|
|
228
|
+
*/ export async function performDeployment(credential, tenantId, options) {
|
|
229
|
+
const shouldMock = process.env.FIGMA_MOCK_CONTROL_PLANE === 'true';
|
|
210
230
|
if (shouldMock) {
|
|
211
231
|
// MOCK IMPLEMENTATION: Return mock deployment status
|
|
212
232
|
log.debug('Using mock Control Plane API for performDeployment (FIGMA_MOCK_CONTROL_PLANE != "false")');
|
|
213
233
|
return {
|
|
214
234
|
deploymentId: options.deploymentId,
|
|
215
|
-
message: 'Deployment initiated successfully'
|
|
235
|
+
message: 'Deployment initiated successfully',
|
|
236
|
+
tenantDomains: [
|
|
237
|
+
'example.figmasource.site'
|
|
238
|
+
]
|
|
216
239
|
};
|
|
217
240
|
}
|
|
241
|
+
const url = `${getControlPlaneBaseUrl()}/v1/cms/tenant/${tenantId}/deploy/perform`;
|
|
242
|
+
log.debug(`Calling performDeployment API at ${url}`);
|
|
218
243
|
// REAL API IMPLEMENTATION
|
|
219
|
-
const response = await
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
244
|
+
const response = await controlPlaneFetch({
|
|
245
|
+
context: 'perform deployment',
|
|
246
|
+
options: {
|
|
247
|
+
body: JSON.stringify({
|
|
248
|
+
deployment_id: options.deploymentId
|
|
249
|
+
}),
|
|
250
|
+
headers: {
|
|
251
|
+
...getAuthHeaders(credential),
|
|
252
|
+
'Content-Type': 'application/json'
|
|
253
|
+
},
|
|
254
|
+
method: 'POST'
|
|
226
255
|
},
|
|
227
|
-
|
|
256
|
+
url
|
|
228
257
|
});
|
|
229
|
-
if (!response.ok) {
|
|
230
|
-
throw new ControlPlaneError(`Failed to perform deployment: ${response.status} ${response.statusText}`, response.status);
|
|
231
|
-
}
|
|
232
258
|
const data = await response.json();
|
|
233
259
|
// Map API response to our interface
|
|
234
260
|
return {
|
|
235
261
|
deploymentId: data.meta.deployment_id,
|
|
236
|
-
message: data.meta.message || 'Deployment initiated'
|
|
262
|
+
message: data.meta.message || 'Deployment initiated',
|
|
263
|
+
tenantDomains: data.meta.tenant_domains
|
|
237
264
|
};
|
|
238
265
|
}
|
|
239
|
-
|
|
240
|
-
|
|
266
|
+
/**
|
|
267
|
+
* Get bootstrap info for a CMS resource
|
|
268
|
+
* Maps to: GET /v1/cms/:cmsResourceId/bootstrap
|
|
269
|
+
*
|
|
270
|
+
* @param accessToken - OAuth access token
|
|
271
|
+
* @param cmsResourceId - CMS Resource ID (project ID)
|
|
272
|
+
* @param environmentName - Optional environment name filter
|
|
273
|
+
*/ export async function getBootstrapInfo(credential, cmsResourceId, environmentName) {
|
|
274
|
+
const baseUrl = getControlPlaneBaseUrl();
|
|
275
|
+
let url = `${baseUrl}/v1/cms/${cmsResourceId}/bootstrap`;
|
|
276
|
+
if (environmentName) {
|
|
277
|
+
url += `?environment_name=${encodeURIComponent(environmentName)}`;
|
|
278
|
+
}
|
|
279
|
+
log.debug(`Calling getBootstrapInfo API at ${url}`);
|
|
280
|
+
const response = await controlPlaneFetch({
|
|
281
|
+
context: 'get bootstrap info',
|
|
282
|
+
options: {
|
|
283
|
+
headers: getAuthHeaders(credential)
|
|
284
|
+
},
|
|
285
|
+
url
|
|
286
|
+
});
|
|
287
|
+
const data = await response.json();
|
|
288
|
+
return {
|
|
289
|
+
environments: data.meta.environments.map((env)=>({
|
|
290
|
+
name: env.name,
|
|
291
|
+
contentSystemId: env.content_system_id,
|
|
292
|
+
tenantInstanceId: env.tenant_instance_id
|
|
293
|
+
})),
|
|
294
|
+
oauthCredentials: {
|
|
295
|
+
oauthClientId: data.meta.oauth_credentials.oauth_client_id,
|
|
296
|
+
oauthClientSecret: data.meta.oauth_credentials.oauth_client_secret
|
|
297
|
+
}
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Resolve a CMS Resource ID from a legacy dataset (content system) ID.
|
|
302
|
+
* Maps to: GET /v1/cms/dataset/:datasetId
|
|
303
|
+
*
|
|
304
|
+
* Used during upgrade migration to convert old FIGMA_CONTENT_API_CONTENT_SYSTEM_ID
|
|
305
|
+
* into the new FIGMA_PROJECT_ID (CMS Resource ID).
|
|
306
|
+
*/ export async function getCmsResourceId(credential, datasetId) {
|
|
307
|
+
const url = `${getControlPlaneBaseUrl()}/v1/cms/dataset/${datasetId}`;
|
|
308
|
+
log.debug(`Calling getCmsResourceId API at ${url}`);
|
|
309
|
+
const response = await controlPlaneFetch({
|
|
310
|
+
context: 'get CMS resource ID from dataset',
|
|
311
|
+
options: {
|
|
312
|
+
headers: getAuthHeaders(credential)
|
|
313
|
+
},
|
|
314
|
+
url
|
|
315
|
+
});
|
|
316
|
+
const data = await response.json();
|
|
317
|
+
return data.meta.cms_resource_id;
|
|
318
|
+
}
|
|
319
|
+
const MAX_RETRIES = 3;
|
|
320
|
+
const INITIAL_RETRY_DELAY = 1000;
|
|
321
|
+
function sleep(ms) {
|
|
322
|
+
return new Promise((resolve)=>setTimeout(resolve, ms));
|
|
323
|
+
}
|
|
324
|
+
async function controlPlaneFetch(params) {
|
|
325
|
+
const { context, options, url } = params;
|
|
326
|
+
let lastError;
|
|
327
|
+
for(let attempt = 0; attempt < MAX_RETRIES; attempt++){
|
|
328
|
+
try {
|
|
329
|
+
const response = await fetch(url, options);
|
|
330
|
+
if (response.ok) {
|
|
331
|
+
return response;
|
|
332
|
+
}
|
|
333
|
+
if (response.status < 500) {
|
|
334
|
+
throw new ControlPlaneError(await parseControlPlaneApiError({
|
|
335
|
+
context,
|
|
336
|
+
response
|
|
337
|
+
}), response.status);
|
|
338
|
+
}
|
|
339
|
+
lastError = new ControlPlaneError(await parseControlPlaneApiError({
|
|
340
|
+
context,
|
|
341
|
+
response
|
|
342
|
+
}), response.status);
|
|
343
|
+
} catch (error) {
|
|
344
|
+
if (error instanceof ControlPlaneError) {
|
|
345
|
+
throw error;
|
|
346
|
+
}
|
|
347
|
+
lastError = error instanceof Error ? error : new Error('Unknown error');
|
|
348
|
+
}
|
|
349
|
+
if (attempt < MAX_RETRIES - 1) {
|
|
350
|
+
await sleep(INITIAL_RETRY_DELAY * Math.pow(2, attempt));
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
throw new ControlPlaneError(`Network error while ${context}: ${lastError?.message || 'Unknown error'}`, undefined, lastError);
|
|
354
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extract a human-readable error message from a non-ok control-plane API Response.
|
|
3
|
+
*
|
|
4
|
+
* Sinatra's error helpers (api_error, api_reject, api_not_found, api_needs_upgrade)
|
|
5
|
+
* all serialize the user-facing string under a `message` key. Surfacing it lets the
|
|
6
|
+
* CLI show the real reason (e.g. "Deployment package is too large...") instead of a
|
|
7
|
+
* bare status code.
|
|
8
|
+
*
|
|
9
|
+
* Scoped to JSON `{ message }` bodies. S3 upload errors arrive as XML and need a
|
|
10
|
+
* separate parser.
|
|
11
|
+
*
|
|
12
|
+
* Only called on the error path, immediately before throwing — the body is never read
|
|
13
|
+
* again, so consuming it here is safe (no clone needed). Never throws: any parse
|
|
14
|
+
* failure or missing message falls back to the HTTP status line.
|
|
15
|
+
*/
|
|
16
|
+
export declare function parseControlPlaneApiError(params: {
|
|
17
|
+
context: string;
|
|
18
|
+
response: Response;
|
|
19
|
+
}): Promise<string>;
|
|
20
|
+
/**
|
|
21
|
+
* Extract a human-readable error message from a non-ok S3 upload Response.
|
|
22
|
+
*
|
|
23
|
+
* S3 reports failures (e.g. SignatureDoesNotMatch, AccessDenied / expired signatures)
|
|
24
|
+
* as an XML document whose first `<Code>` and `<Message>` carry the reason — not the
|
|
25
|
+
* JSON shape {@link parseControlPlaneApiError} expects. The document also includes
|
|
26
|
+
* sibling tags (StringToSign, CanonicalRequest, RequestId), so we extract only those
|
|
27
|
+
* two so the CLI can show the real reason instead of a bare status code.
|
|
28
|
+
*
|
|
29
|
+
* Only called on the error path, immediately before throwing — the body is never read
|
|
30
|
+
* again, so consuming it here is safe (no clone needed). Never throws: any parse
|
|
31
|
+
* failure or missing fields falls back to the HTTP status line.
|
|
32
|
+
*/
|
|
33
|
+
export declare function parseS3Error(params: {
|
|
34
|
+
context: string;
|
|
35
|
+
response: Response;
|
|
36
|
+
}): Promise<string>;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extract a human-readable error message from a non-ok control-plane API Response.
|
|
3
|
+
*
|
|
4
|
+
* Sinatra's error helpers (api_error, api_reject, api_not_found, api_needs_upgrade)
|
|
5
|
+
* all serialize the user-facing string under a `message` key. Surfacing it lets the
|
|
6
|
+
* CLI show the real reason (e.g. "Deployment package is too large...") instead of a
|
|
7
|
+
* bare status code.
|
|
8
|
+
*
|
|
9
|
+
* Scoped to JSON `{ message }` bodies. S3 upload errors arrive as XML and need a
|
|
10
|
+
* separate parser.
|
|
11
|
+
*
|
|
12
|
+
* Only called on the error path, immediately before throwing — the body is never read
|
|
13
|
+
* again, so consuming it here is safe (no clone needed). Never throws: any parse
|
|
14
|
+
* failure or missing message falls back to the HTTP status line.
|
|
15
|
+
*/ export async function parseControlPlaneApiError(params) {
|
|
16
|
+
const { context, response } = params;
|
|
17
|
+
const fallback = `Failed to ${context}: ${response.status} ${response.statusText}`;
|
|
18
|
+
try {
|
|
19
|
+
const body = await response.json();
|
|
20
|
+
if (typeof body.message === 'string' && body.message.trim().length > 0) {
|
|
21
|
+
return `Failed to ${context}: ${response.status} ${body.message.trim()}`;
|
|
22
|
+
}
|
|
23
|
+
} catch {
|
|
24
|
+
// Non-JSON body, empty body, or no .json() — fall back to the status line.
|
|
25
|
+
}
|
|
26
|
+
return fallback;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Extract a human-readable error message from a non-ok S3 upload Response.
|
|
30
|
+
*
|
|
31
|
+
* S3 reports failures (e.g. SignatureDoesNotMatch, AccessDenied / expired signatures)
|
|
32
|
+
* as an XML document whose first `<Code>` and `<Message>` carry the reason — not the
|
|
33
|
+
* JSON shape {@link parseControlPlaneApiError} expects. The document also includes
|
|
34
|
+
* sibling tags (StringToSign, CanonicalRequest, RequestId), so we extract only those
|
|
35
|
+
* two so the CLI can show the real reason instead of a bare status code.
|
|
36
|
+
*
|
|
37
|
+
* Only called on the error path, immediately before throwing — the body is never read
|
|
38
|
+
* again, so consuming it here is safe (no clone needed). Never throws: any parse
|
|
39
|
+
* failure or missing fields falls back to the HTTP status line.
|
|
40
|
+
*/ export async function parseS3Error(params) {
|
|
41
|
+
const { context, response } = params;
|
|
42
|
+
const fallback = `Failed to ${context}: ${response.status} ${response.statusText}`;
|
|
43
|
+
try {
|
|
44
|
+
const body = await response.text();
|
|
45
|
+
const code = extractXmlTag(body, 'Code');
|
|
46
|
+
const message = extractXmlTag(body, 'Message');
|
|
47
|
+
if (message) {
|
|
48
|
+
return `Failed to ${context}: ${response.status} ${code ? `${code}: ` : ''}${message}`;
|
|
49
|
+
}
|
|
50
|
+
if (code) {
|
|
51
|
+
return `Failed to ${context}: ${response.status} ${code}`;
|
|
52
|
+
}
|
|
53
|
+
} catch {
|
|
54
|
+
// Non-XML body, empty body, or no .text() — fall back to the status line.
|
|
55
|
+
}
|
|
56
|
+
return fallback;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Pull the trimmed text content of a single non-nested XML tag (e.g. `<Code>`).
|
|
60
|
+
* Returns undefined when the tag is absent or empty. S3 error documents are flat,
|
|
61
|
+
* so a narrow regex is sufficient — no general XML parsing needed.
|
|
62
|
+
*/ function extractXmlTag(xml, tag) {
|
|
63
|
+
const match = new RegExp(`<${tag}>([^<]*)</${tag}>`).exec(xml);
|
|
64
|
+
const value = match?.[1]?.trim();
|
|
65
|
+
return value && value.length > 0 ? value : undefined;
|
|
66
|
+
}
|
package/dist/api/figma-api.d.ts
CHANGED
|
@@ -4,7 +4,17 @@
|
|
|
4
4
|
* Client for Figma REST API (Pixie) endpoints
|
|
5
5
|
* Handles project token generation and other CMS-related API calls
|
|
6
6
|
*/
|
|
7
|
+
import type { AuthCredential } from '../auth/credentials.js';
|
|
7
8
|
import type { ProjectToken } from '../auth/types.js';
|
|
9
|
+
/**
|
|
10
|
+
* User info from Figma API /v1/me endpoint
|
|
11
|
+
*/
|
|
12
|
+
export type FigmaUserInfo = {
|
|
13
|
+
email: string;
|
|
14
|
+
handle: string;
|
|
15
|
+
id: string;
|
|
16
|
+
img_url: string;
|
|
17
|
+
};
|
|
8
18
|
/**
|
|
9
19
|
* Error thrown when Figma API calls fail
|
|
10
20
|
*/
|
|
@@ -20,12 +30,23 @@ export declare class FigmaApiError extends Error {
|
|
|
20
30
|
* requests to the Content API. The token contains the CMS ID and
|
|
21
31
|
* user identifying information in its claims.
|
|
22
32
|
*
|
|
23
|
-
* Endpoint:
|
|
33
|
+
* Endpoint: POST https://api.figma.com/v1/cms/content-systems/:id/token/
|
|
24
34
|
*
|
|
25
35
|
* @param accessToken - OAuth access token for authentication
|
|
26
36
|
* @param tenantId - The tenant/CMS ID
|
|
27
37
|
* @returns ProjectToken with JWT and expiry information
|
|
28
38
|
* @throws {FigmaApiError} If the API call fails
|
|
29
39
|
*/
|
|
30
|
-
export declare function getProjectToken(
|
|
31
|
-
|
|
40
|
+
export declare function getProjectToken(credential: AuthCredential, tenantId: string): Promise<ProjectToken>;
|
|
41
|
+
export declare function getPayloadAdminToken(credential: AuthCredential, environmentId: string): Promise<ProjectToken>;
|
|
42
|
+
/**
|
|
43
|
+
* Get user info from Figma API
|
|
44
|
+
*
|
|
45
|
+
* Endpoint: GET https://api.figma.com/v1/me
|
|
46
|
+
* Requires OAuth access_token (not project token)
|
|
47
|
+
*
|
|
48
|
+
* @param accessToken - OAuth access token for authentication
|
|
49
|
+
* @returns FigmaUserInfo with user profile data
|
|
50
|
+
* @throws {FigmaApiError} If the API call fails
|
|
51
|
+
*/
|
|
52
|
+
export declare function getUserInfo(credential: AuthCredential): Promise<FigmaUserInfo>;
|