@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
|
@@ -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,40 @@ 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(
|
|
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>;
|
|
124
174
|
//# sourceMappingURL=control-plane.d.ts.map
|
|
@@ -2,18 +2,13 @@
|
|
|
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
|
-
};
|
|
13
8
|
/**
|
|
14
9
|
* Get the Control Plane API base URL based on environment
|
|
15
10
|
*/ function getControlPlaneBaseUrl() {
|
|
16
|
-
return
|
|
11
|
+
return getEnvConfig().apiBaseUrl;
|
|
17
12
|
}
|
|
18
13
|
/**
|
|
19
14
|
* Error thrown when Control Plane API calls fail
|
|
@@ -31,10 +26,8 @@ import * as log from '../utils/log.js';
|
|
|
31
26
|
*
|
|
32
27
|
* @param accessToken - OAuth access token
|
|
33
28
|
* @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';
|
|
29
|
+
*/ export async function listTenants(credential) {
|
|
30
|
+
const shouldMock = process.env.FIGMA_MOCK_CONTROL_PLANE === 'true';
|
|
38
31
|
if (shouldMock) {
|
|
39
32
|
// MOCK IMPLEMENTATION: Return sample tenants for testing
|
|
40
33
|
log.debug('Using mock Control Plane API for listTenants (FIGMA_MOCK_CONTROL_PLANE != "false")');
|
|
@@ -58,14 +51,13 @@ import * as log from '../utils/log.js';
|
|
|
58
51
|
];
|
|
59
52
|
}
|
|
60
53
|
// REAL API IMPLEMENTATION
|
|
61
|
-
const response = await
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
54
|
+
const response = await controlPlaneFetch({
|
|
55
|
+
context: 'list tenants',
|
|
56
|
+
options: {
|
|
57
|
+
headers: getAuthHeaders(credential)
|
|
58
|
+
},
|
|
59
|
+
url: `${getControlPlaneBaseUrl()}/v1/tenant`
|
|
65
60
|
});
|
|
66
|
-
if (!response.ok) {
|
|
67
|
-
throw new ControlPlaneError(`Failed to list tenants: ${response.status} ${response.statusText}`, response.status);
|
|
68
|
-
}
|
|
69
61
|
return response.json();
|
|
70
62
|
}
|
|
71
63
|
/**
|
|
@@ -75,9 +67,9 @@ import * as log from '../utils/log.js';
|
|
|
75
67
|
* @param accessToken - OAuth access token
|
|
76
68
|
* @param options - Tenant creation options
|
|
77
69
|
* @returns Newly created tenant
|
|
78
|
-
*/ export async function createTenant(
|
|
70
|
+
*/ export async function createTenant(credential, options) {
|
|
79
71
|
// Check if control plane API should be mocked
|
|
80
|
-
const shouldMock = process.env.FIGMA_MOCK_CONTROL_PLANE
|
|
72
|
+
const shouldMock = process.env.FIGMA_MOCK_CONTROL_PLANE === 'true';
|
|
81
73
|
if (shouldMock) {
|
|
82
74
|
// MOCK IMPLEMENTATION: Generate mock tenant for testing
|
|
83
75
|
log.debug('Using mock Control Plane API for createTenant (FIGMA_MOCK_CONTROL_PLANE != "false")');
|
|
@@ -94,19 +86,20 @@ import * as log from '../utils/log.js';
|
|
|
94
86
|
};
|
|
95
87
|
}
|
|
96
88
|
// REAL API IMPLEMENTATION
|
|
97
|
-
const response = await
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
89
|
+
const response = await controlPlaneFetch({
|
|
90
|
+
context: 'create tenant',
|
|
91
|
+
options: {
|
|
92
|
+
body: JSON.stringify({
|
|
93
|
+
name: options.name
|
|
94
|
+
}),
|
|
95
|
+
headers: {
|
|
96
|
+
...getAuthHeaders(credential),
|
|
97
|
+
'Content-Type': 'application/json'
|
|
98
|
+
},
|
|
99
|
+
method: 'POST'
|
|
104
100
|
},
|
|
105
|
-
|
|
101
|
+
url: `${getControlPlaneBaseUrl()}/v1/tenant`
|
|
106
102
|
});
|
|
107
|
-
if (!response.ok) {
|
|
108
|
-
throw new ControlPlaneError(`Failed to create tenant: ${response.status} ${response.statusText}`, response.status);
|
|
109
|
-
}
|
|
110
103
|
return response.json();
|
|
111
104
|
}
|
|
112
105
|
/**
|
|
@@ -116,9 +109,9 @@ import * as log from '../utils/log.js';
|
|
|
116
109
|
* @param accessToken - OAuth access token
|
|
117
110
|
* @param tenantId - Tenant ID
|
|
118
111
|
* @returns Tenant details
|
|
119
|
-
*/ export async function getTenantDetails(
|
|
112
|
+
*/ export async function getTenantDetails(credential, tenantId) {
|
|
120
113
|
// Check if control plane API should be mocked
|
|
121
|
-
const shouldMock = process.env.FIGMA_MOCK_CONTROL_PLANE
|
|
114
|
+
const shouldMock = process.env.FIGMA_MOCK_CONTROL_PLANE === 'true';
|
|
122
115
|
if (shouldMock) {
|
|
123
116
|
// MOCK IMPLEMENTATION: Return mock tenant details for testing
|
|
124
117
|
log.debug('Using mock Control Plane API for getTenantDetails (FIGMA_MOCK_CONTROL_PLANE != "false")');
|
|
@@ -132,14 +125,13 @@ import * as log from '../utils/log.js';
|
|
|
132
125
|
};
|
|
133
126
|
}
|
|
134
127
|
// REAL API IMPLEMENTATION
|
|
135
|
-
const response = await
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
128
|
+
const response = await controlPlaneFetch({
|
|
129
|
+
context: 'get tenant details',
|
|
130
|
+
options: {
|
|
131
|
+
headers: getAuthHeaders(credential)
|
|
132
|
+
},
|
|
133
|
+
url: `${getControlPlaneBaseUrl()}/v1/tenant/${tenantId}`
|
|
139
134
|
});
|
|
140
|
-
if (!response.ok) {
|
|
141
|
-
throw new ControlPlaneError(`Failed to get tenant details: ${response.status} ${response.statusText}`, response.status);
|
|
142
|
-
}
|
|
143
135
|
return response.json();
|
|
144
136
|
}
|
|
145
137
|
/**
|
|
@@ -150,12 +142,12 @@ import * as log from '../utils/log.js';
|
|
|
150
142
|
* @param tenantId - Tenant ID
|
|
151
143
|
* @param options - Deployment creation options
|
|
152
144
|
* @returns Deployment ID and upload URLs
|
|
153
|
-
*/ export async function createDeployment(
|
|
145
|
+
*/ export async function createDeployment(credential, tenantId, options) {
|
|
154
146
|
// Check if control plane API should be mocked
|
|
155
|
-
const shouldMock = process.env.FIGMA_MOCK_CONTROL_PLANE
|
|
147
|
+
const shouldMock = process.env.FIGMA_MOCK_CONTROL_PLANE === 'true';
|
|
156
148
|
if (shouldMock) {
|
|
157
149
|
// MOCK IMPLEMENTATION: Generate mock deployment and signed URLs
|
|
158
|
-
log.debug('Using mock Control Plane API for createDeployment (FIGMA_MOCK_CONTROL_PLANE
|
|
150
|
+
log.debug('Using mock Control Plane API for createDeployment (FIGMA_MOCK_CONTROL_PLANE === "true")');
|
|
159
151
|
const deploymentId = `deploy_${Math.random().toString(36).substring(2, 11)}`;
|
|
160
152
|
const mockBucket = 'figma-cms-deployments-mock';
|
|
161
153
|
const mockRegion = 'us-west-2';
|
|
@@ -166,33 +158,61 @@ import * as log from '../utils/log.js';
|
|
|
166
158
|
const encodedPath = encodeURIComponent(assetPath);
|
|
167
159
|
staticAssetUploadUrls[assetPath] = `${mockBaseUrl}/${tenantId}/${deploymentId}/static/${encodedPath}?X-Amz-Signature=mock`;
|
|
168
160
|
}
|
|
161
|
+
// Generate mock signed URLs for page assets
|
|
162
|
+
const pageUploadUrls = {};
|
|
163
|
+
for (const pageData of Object.values(options.pages)){
|
|
164
|
+
for (const assetPath of pageData.assets){
|
|
165
|
+
const encodedPath = encodeURIComponent(assetPath);
|
|
166
|
+
pageUploadUrls[assetPath] = `${mockBaseUrl}/${tenantId}/${deploymentId}/pages/${encodedPath}?X-Amz-Signature=mock`;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
169
|
// Generate mock signed URL for code zip
|
|
170
170
|
const codeUploadUrl = `${mockBaseUrl}/${tenantId}/${deploymentId}/lambda.zip?X-Amz-Signature=mock`;
|
|
171
171
|
return {
|
|
172
172
|
codeUploadUrl,
|
|
173
173
|
deploymentId,
|
|
174
|
+
pageUploadUrls,
|
|
174
175
|
staticAssetUploadUrls
|
|
175
176
|
};
|
|
176
177
|
}
|
|
178
|
+
const url = `${getControlPlaneBaseUrl()}/v1/cms/tenant/${tenantId}/deploy/create`;
|
|
179
|
+
log.debug(`Calling createDeployment API at ${url}`);
|
|
180
|
+
// Build pages payload: { route: { assets: [...] } }
|
|
181
|
+
const pages = {};
|
|
182
|
+
for (const [route, pageData] of Object.entries(options.pages)){
|
|
183
|
+
pages[route] = {
|
|
184
|
+
assets: pageData.assets
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
const body = {
|
|
188
|
+
pages,
|
|
189
|
+
static_assets: options.staticAssets
|
|
190
|
+
};
|
|
191
|
+
if (options.adapter) {
|
|
192
|
+
body.adapter = options.adapter;
|
|
193
|
+
}
|
|
194
|
+
if (options.fallback) {
|
|
195
|
+
body.fallback = options.fallback;
|
|
196
|
+
}
|
|
177
197
|
// REAL API IMPLEMENTATION
|
|
178
|
-
const response = await
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
198
|
+
const response = await controlPlaneFetch({
|
|
199
|
+
context: 'create deployment',
|
|
200
|
+
options: {
|
|
201
|
+
body: JSON.stringify(body),
|
|
202
|
+
headers: {
|
|
203
|
+
...getAuthHeaders(credential),
|
|
204
|
+
'Content-Type': 'application/json'
|
|
205
|
+
},
|
|
206
|
+
method: 'POST'
|
|
185
207
|
},
|
|
186
|
-
|
|
208
|
+
url
|
|
187
209
|
});
|
|
188
|
-
if (!response.ok) {
|
|
189
|
-
throw new ControlPlaneError(`Failed to create deployment: ${response.status} ${response.statusText}`, response.status);
|
|
190
|
-
}
|
|
191
210
|
const data = await response.json();
|
|
192
211
|
// Map API response format to our interface
|
|
193
212
|
return {
|
|
194
|
-
codeUploadUrl: data.meta.
|
|
213
|
+
codeUploadUrl: data.meta.lambda_zip_upload_url,
|
|
195
214
|
deploymentId: data.meta.deployment_id,
|
|
215
|
+
pageUploadUrls: data.meta.page_upload_urls,
|
|
196
216
|
staticAssetUploadUrls: data.meta.static_asset_upload_urls
|
|
197
217
|
};
|
|
198
218
|
}
|
|
@@ -204,37 +224,126 @@ import * as log from '../utils/log.js';
|
|
|
204
224
|
* @param tenantId - Tenant ID
|
|
205
225
|
* @param options - Deployment perform options
|
|
206
226
|
* @returns Deployment status and message
|
|
207
|
-
*/ export async function performDeployment(
|
|
208
|
-
|
|
209
|
-
const shouldMock = process.env.FIGMA_MOCK_CONTROL_PLANE !== 'false';
|
|
227
|
+
*/ export async function performDeployment(credential, tenantId, options) {
|
|
228
|
+
const shouldMock = process.env.FIGMA_MOCK_CONTROL_PLANE === 'true';
|
|
210
229
|
if (shouldMock) {
|
|
211
230
|
// MOCK IMPLEMENTATION: Return mock deployment status
|
|
212
231
|
log.debug('Using mock Control Plane API for performDeployment (FIGMA_MOCK_CONTROL_PLANE != "false")');
|
|
213
232
|
return {
|
|
214
233
|
deploymentId: options.deploymentId,
|
|
215
|
-
message: 'Deployment initiated successfully'
|
|
234
|
+
message: 'Deployment initiated successfully',
|
|
235
|
+
tenantDomains: [
|
|
236
|
+
'example.figmasource.site'
|
|
237
|
+
]
|
|
216
238
|
};
|
|
217
239
|
}
|
|
240
|
+
const url = `${getControlPlaneBaseUrl()}/v1/cms/tenant/${tenantId}/deploy/perform`;
|
|
241
|
+
log.debug(`Calling performDeployment API at ${url}`);
|
|
218
242
|
// REAL API IMPLEMENTATION
|
|
219
|
-
const response = await
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
243
|
+
const response = await controlPlaneFetch({
|
|
244
|
+
context: 'perform deployment',
|
|
245
|
+
options: {
|
|
246
|
+
body: JSON.stringify({
|
|
247
|
+
deployment_id: options.deploymentId
|
|
248
|
+
}),
|
|
249
|
+
headers: {
|
|
250
|
+
...getAuthHeaders(credential),
|
|
251
|
+
'Content-Type': 'application/json'
|
|
252
|
+
},
|
|
253
|
+
method: 'POST'
|
|
226
254
|
},
|
|
227
|
-
|
|
255
|
+
url
|
|
228
256
|
});
|
|
229
|
-
if (!response.ok) {
|
|
230
|
-
throw new ControlPlaneError(`Failed to perform deployment: ${response.status} ${response.statusText}`, response.status);
|
|
231
|
-
}
|
|
232
257
|
const data = await response.json();
|
|
233
258
|
// Map API response to our interface
|
|
234
259
|
return {
|
|
235
260
|
deploymentId: data.meta.deployment_id,
|
|
236
|
-
message: data.meta.message || 'Deployment initiated'
|
|
261
|
+
message: data.meta.message || 'Deployment initiated',
|
|
262
|
+
tenantDomains: data.meta.tenant_domains
|
|
237
263
|
};
|
|
238
264
|
}
|
|
265
|
+
/**
|
|
266
|
+
* Get bootstrap info for a CMS resource
|
|
267
|
+
* Maps to: GET /v1/cms/:cmsResourceId/bootstrap
|
|
268
|
+
*
|
|
269
|
+
* @param accessToken - OAuth access token
|
|
270
|
+
* @param cmsResourceId - CMS Resource ID (project ID)
|
|
271
|
+
* @param environmentName - Optional environment name filter
|
|
272
|
+
*/ export async function getBootstrapInfo(credential, cmsResourceId, environmentName) {
|
|
273
|
+
const baseUrl = getControlPlaneBaseUrl();
|
|
274
|
+
let url = `${baseUrl}/v1/cms/${cmsResourceId}/bootstrap`;
|
|
275
|
+
if (environmentName) {
|
|
276
|
+
url += `?environment_name=${encodeURIComponent(environmentName)}`;
|
|
277
|
+
}
|
|
278
|
+
log.debug(`Calling getBootstrapInfo API at ${url}`);
|
|
279
|
+
const response = await controlPlaneFetch({
|
|
280
|
+
context: 'get bootstrap info',
|
|
281
|
+
options: {
|
|
282
|
+
headers: getAuthHeaders(credential)
|
|
283
|
+
},
|
|
284
|
+
url
|
|
285
|
+
});
|
|
286
|
+
const data = await response.json();
|
|
287
|
+
return {
|
|
288
|
+
environments: data.meta.environments.map((env)=>({
|
|
289
|
+
name: env.name,
|
|
290
|
+
contentSystemId: env.content_system_id,
|
|
291
|
+
tenantInstanceId: env.tenant_instance_id
|
|
292
|
+
})),
|
|
293
|
+
oauthCredentials: {
|
|
294
|
+
oauthClientId: data.meta.oauth_credentials.oauth_client_id,
|
|
295
|
+
oauthClientSecret: data.meta.oauth_credentials.oauth_client_secret
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Resolve a CMS Resource ID from a legacy dataset (content system) ID.
|
|
301
|
+
* Maps to: GET /v1/cms/dataset/:datasetId
|
|
302
|
+
*
|
|
303
|
+
* Used during upgrade migration to convert old FIGMA_CONTENT_API_CONTENT_SYSTEM_ID
|
|
304
|
+
* into the new FIGMA_PROJECT_ID (CMS Resource ID).
|
|
305
|
+
*/ export async function getCmsResourceId(credential, datasetId) {
|
|
306
|
+
const url = `${getControlPlaneBaseUrl()}/v1/cms/dataset/${datasetId}`;
|
|
307
|
+
log.debug(`Calling getCmsResourceId API at ${url}`);
|
|
308
|
+
const response = await controlPlaneFetch({
|
|
309
|
+
context: 'get CMS resource ID from dataset',
|
|
310
|
+
options: {
|
|
311
|
+
headers: getAuthHeaders(credential)
|
|
312
|
+
},
|
|
313
|
+
url
|
|
314
|
+
});
|
|
315
|
+
const data = await response.json();
|
|
316
|
+
return data.meta.cms_resource_id;
|
|
317
|
+
}
|
|
318
|
+
const MAX_RETRIES = 3;
|
|
319
|
+
const INITIAL_RETRY_DELAY = 1000;
|
|
320
|
+
function sleep(ms) {
|
|
321
|
+
return new Promise((resolve)=>setTimeout(resolve, ms));
|
|
322
|
+
}
|
|
323
|
+
async function controlPlaneFetch(params) {
|
|
324
|
+
const { context, options, url } = params;
|
|
325
|
+
let lastError;
|
|
326
|
+
for(let attempt = 0; attempt < MAX_RETRIES; attempt++){
|
|
327
|
+
try {
|
|
328
|
+
const response = await fetch(url, options);
|
|
329
|
+
if (response.ok) {
|
|
330
|
+
return response;
|
|
331
|
+
}
|
|
332
|
+
if (response.status < 500) {
|
|
333
|
+
throw new ControlPlaneError(`Failed to ${context}: ${response.status} ${response.statusText}`, response.status);
|
|
334
|
+
}
|
|
335
|
+
lastError = new ControlPlaneError(`Failed to ${context}: ${response.status} ${response.statusText}`, response.status);
|
|
336
|
+
} catch (error) {
|
|
337
|
+
if (error instanceof ControlPlaneError) {
|
|
338
|
+
throw error;
|
|
339
|
+
}
|
|
340
|
+
lastError = error instanceof Error ? error : new Error('Unknown error');
|
|
341
|
+
}
|
|
342
|
+
if (attempt < MAX_RETRIES - 1) {
|
|
343
|
+
await sleep(INITIAL_RETRY_DELAY * Math.pow(2, attempt));
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
throw new ControlPlaneError(`Network error while ${context}: ${lastError?.message || 'Unknown error'}`, undefined, lastError);
|
|
347
|
+
}
|
|
239
348
|
|
|
240
349
|
//# sourceMappingURL=control-plane.js.map
|
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
|
*/
|
|
@@ -27,5 +37,16 @@ export declare class FigmaApiError extends Error {
|
|
|
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(
|
|
40
|
+
export declare function getProjectToken(credential: AuthCredential, tenantId: string): Promise<ProjectToken>;
|
|
41
|
+
/**
|
|
42
|
+
* Get user info from Figma API
|
|
43
|
+
*
|
|
44
|
+
* Endpoint: GET https://api.figma.com/v1/me
|
|
45
|
+
* Requires OAuth access_token (not project token)
|
|
46
|
+
*
|
|
47
|
+
* @param accessToken - OAuth access token for authentication
|
|
48
|
+
* @returns FigmaUserInfo with user profile data
|
|
49
|
+
* @throws {FigmaApiError} If the API call fails
|
|
50
|
+
*/
|
|
51
|
+
export declare function getUserInfo(credential: AuthCredential): Promise<FigmaUserInfo>;
|
|
31
52
|
//# sourceMappingURL=figma-api.d.ts.map
|