@payloadcms/figma 0.0.1-alpha.6 → 0.0.1-alpha.61
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 +52 -6
- package/dist/api/control-plane.js +174 -72
- package/dist/api/figma-api.d.ts +22 -1
- package/dist/api/figma-api.js +78 -25
- package/dist/auth/callback-server.js +2 -1
- package/dist/auth/credentials.d.ts +21 -0
- package/dist/auth/credentials.js +21 -0
- package/dist/auth/crypto-utils.d.ts +6 -0
- package/dist/auth/crypto-utils.js +16 -14
- package/dist/auth/jwt-validator.d.ts +2 -1
- package/dist/auth/jwt-validator.js +2 -2
- package/dist/auth/oauth-flow.d.ts +17 -3
- package/dist/auth/oauth-flow.js +63 -16
- package/dist/auth/project-token.js +16 -11
- package/dist/auth/refresh.d.ts +2 -1
- package/dist/auth/refresh.js +25 -12
- package/dist/auth/token-store.d.ts +42 -1
- package/dist/auth/token-store.js +118 -14
- package/dist/auth/types.d.ts +17 -4
- package/dist/cli.js +68 -5
- 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 +176 -0
- package/dist/commands/deploy.d.ts +9 -0
- package/dist/commands/deploy.js +178 -151
- package/dist/commands/env.d.ts +13 -0
- package/dist/commands/env.js +88 -0
- package/dist/commands/init.d.ts +3 -5
- package/dist/commands/init.js +165 -148
- package/dist/commands/list-tokens.d.ts +3 -3
- package/dist/commands/list-tokens.js +22 -7
- package/dist/commands/login.d.ts +8 -1
- package/dist/commands/login.js +33 -15
- package/dist/commands/logout.d.ts +5 -4
- package/dist/commands/logout.js +56 -13
- package/dist/commands/upgrade.d.ts +5 -0
- package/dist/commands/upgrade.js +331 -0
- package/dist/config/oauth.d.ts +4 -14
- package/dist/config/oauth.js +18 -40
- package/dist/constants.d.ts +44 -19
- package/dist/constants.js +73 -20
- package/dist/db-content-api/README.md +98 -0
- package/dist/db-content-api/generated/content-api-types.d.ts +3972 -0
- package/dist/db-content-api/generated/content-api-types.js +7 -0
- package/dist/db-content-api/index.d.ts +21 -0
- package/dist/db-content-api/index.js +914 -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 +59 -0
- package/dist/db-content-api/utilities/auth.d.ts +30 -0
- package/dist/db-content-api/utilities/auth.js +81 -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/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/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/index.js +50 -6
- package/dist/oauth/components/LoginButton/index.scss +50 -3
- package/dist/oauth/components/LogoutButton/index.js +5 -4
- package/dist/oauth/defaults.js +67 -10
- package/dist/oauth/endpoints/getLoginEndpoint.js +77 -24
- package/dist/oauth/endpoints/getLogoutEndpoint.js +7 -4
- package/dist/oauth/index.js +40 -13
- package/dist/oauth/strategy/index.d.ts +0 -2
- package/dist/oauth/strategy/index.js +40 -17
- package/dist/oauth/types.d.ts +6 -6
- 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/build-config.d.ts +18 -15
- package/dist/plugin/build-config.js +213 -18
- 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 +42 -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 +36 -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 +56 -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 +2 -0
- package/dist/storage-content-api/utilities/index.js +3 -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 +8 -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 +14 -0
- package/dist/utils/build-lambda-zip.js +81 -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.js +3 -2
- 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 +29 -11
- package/dist/utils/package-manager.d.ts +24 -0
- package/dist/utils/package-manager.js +53 -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 +70 -11
- package/dist/utils/payload-package-check.d.ts +12 -1
- package/dist/utils/payload-package-check.js +63 -5
- package/dist/utils/project.d.ts +3 -2
- package/dist/utils/project.js +29 -15
- 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.js +11 -5
- 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 +33 -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,10 @@ export interface CreateTenantOptions {
|
|
|
27
28
|
* Options for creating a new deployment
|
|
28
29
|
*/
|
|
29
30
|
export interface CreateDeploymentOptions {
|
|
31
|
+
/** Pages keyed by route, each with its associated asset keys */
|
|
32
|
+
pages: Record<string, {
|
|
33
|
+
assets: string[];
|
|
34
|
+
}>;
|
|
30
35
|
/** List of static asset paths that need upload URLs */
|
|
31
36
|
staticAssets: string[];
|
|
32
37
|
}
|
|
@@ -38,14 +43,17 @@ export interface CreateDeploymentResponse {
|
|
|
38
43
|
codeUploadUrl: string;
|
|
39
44
|
/** Unique deployment ID */
|
|
40
45
|
deploymentId: string;
|
|
46
|
+
/** Map of page asset paths to their signed S3 upload URLs */
|
|
47
|
+
pageUploadUrls: Record<string, string>;
|
|
41
48
|
/** Map of static asset paths to their signed S3 upload URLs */
|
|
42
49
|
staticAssetUploadUrls: Record<string, string>;
|
|
43
50
|
}
|
|
44
51
|
export interface CreateDeploymentApiResponse {
|
|
45
52
|
error: boolean;
|
|
46
53
|
meta: {
|
|
47
|
-
code_upload_url: string;
|
|
48
54
|
deployment_id: string;
|
|
55
|
+
lambda_zip_upload_url: string;
|
|
56
|
+
page_upload_urls: Record<string, string>;
|
|
49
57
|
static_asset_upload_urls: Record<string, string>;
|
|
50
58
|
};
|
|
51
59
|
status: number;
|
|
@@ -65,6 +73,8 @@ export interface PerformDeploymentResponse {
|
|
|
65
73
|
deploymentId: string;
|
|
66
74
|
/** Status message */
|
|
67
75
|
message: string;
|
|
76
|
+
/** List of tenant domains */
|
|
77
|
+
tenantDomains: string[];
|
|
68
78
|
}
|
|
69
79
|
export interface PerformDeploymentApiResponse {
|
|
70
80
|
error: boolean;
|
|
@@ -72,6 +82,7 @@ export interface PerformDeploymentApiResponse {
|
|
|
72
82
|
deployment_id: string;
|
|
73
83
|
message: string;
|
|
74
84
|
status: string;
|
|
85
|
+
tenant_domains: string[];
|
|
75
86
|
};
|
|
76
87
|
status: number;
|
|
77
88
|
}
|
|
@@ -82,7 +93,7 @@ export interface PerformDeploymentApiResponse {
|
|
|
82
93
|
* @param accessToken - OAuth access token
|
|
83
94
|
* @returns Array of tenant instances
|
|
84
95
|
*/
|
|
85
|
-
export declare function listTenants(
|
|
96
|
+
export declare function listTenants(credential: AuthCredential): Promise<Tenant[]>;
|
|
86
97
|
/**
|
|
87
98
|
* Create a new tenant instance
|
|
88
99
|
* Maps to: POST /v1/tenant
|
|
@@ -91,7 +102,7 @@ export declare function listTenants(accessToken: string): Promise<Tenant[]>;
|
|
|
91
102
|
* @param options - Tenant creation options
|
|
92
103
|
* @returns Newly created tenant
|
|
93
104
|
*/
|
|
94
|
-
export declare function createTenant(
|
|
105
|
+
export declare function createTenant(credential: AuthCredential, options: CreateTenantOptions): Promise<Tenant>;
|
|
95
106
|
/**
|
|
96
107
|
* Get details for a specific tenant
|
|
97
108
|
* Maps to: GET /v1/tenant/{tenant_id}
|
|
@@ -100,7 +111,7 @@ export declare function createTenant(accessToken: string, options: CreateTenantO
|
|
|
100
111
|
* @param tenantId - Tenant ID
|
|
101
112
|
* @returns Tenant details
|
|
102
113
|
*/
|
|
103
|
-
export declare function getTenantDetails(
|
|
114
|
+
export declare function getTenantDetails(credential: AuthCredential, tenantId: string): Promise<Tenant>;
|
|
104
115
|
/**
|
|
105
116
|
* Create a new deployment and get signed upload URLs
|
|
106
117
|
* Maps to: POST /v1/tenant/{tenant_id}/deploy/create
|
|
@@ -110,7 +121,7 @@ export declare function getTenantDetails(accessToken: string, tenantId: string):
|
|
|
110
121
|
* @param options - Deployment creation options
|
|
111
122
|
* @returns Deployment ID and upload URLs
|
|
112
123
|
*/
|
|
113
|
-
export declare function createDeployment(
|
|
124
|
+
export declare function createDeployment(credential: AuthCredential, tenantId: string, options: CreateDeploymentOptions): Promise<CreateDeploymentResponse>;
|
|
114
125
|
/**
|
|
115
126
|
* Perform deployment for a created deployment ID
|
|
116
127
|
* Maps to: POST /v1/tenant/{tenant_id}/deploy/perform
|
|
@@ -120,5 +131,40 @@ export declare function createDeployment(accessToken: string, tenantId: string,
|
|
|
120
131
|
* @param options - Deployment perform options
|
|
121
132
|
* @returns Deployment status and message
|
|
122
133
|
*/
|
|
123
|
-
export declare function performDeployment(
|
|
134
|
+
export declare function performDeployment(credential: AuthCredential, tenantId: string, options: PerformDeploymentOptions): Promise<PerformDeploymentResponse>;
|
|
135
|
+
/**
|
|
136
|
+
* A single environment returned by the bootstrap endpoint
|
|
137
|
+
*/
|
|
138
|
+
export type BootstrapEnvironment = {
|
|
139
|
+
contentSystemId: string;
|
|
140
|
+
name: string;
|
|
141
|
+
tenantInstanceId: string;
|
|
142
|
+
};
|
|
143
|
+
/**
|
|
144
|
+
* Response from the bootstrap endpoint (camelCased)
|
|
145
|
+
*/
|
|
146
|
+
export type BootstrapInfo = {
|
|
147
|
+
environments: BootstrapEnvironment[];
|
|
148
|
+
oauthCredentials: {
|
|
149
|
+
oauthClientId: string;
|
|
150
|
+
oauthClientSecret: string;
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
/**
|
|
154
|
+
* Get bootstrap info for a CMS resource
|
|
155
|
+
* Maps to: GET /v1/cms/:cmsResourceId/bootstrap
|
|
156
|
+
*
|
|
157
|
+
* @param accessToken - OAuth access token
|
|
158
|
+
* @param cmsResourceId - CMS Resource ID (project ID)
|
|
159
|
+
* @param environmentName - Optional environment name filter
|
|
160
|
+
*/
|
|
161
|
+
export declare function getBootstrapInfo(credential: AuthCredential, cmsResourceId: string, environmentName?: string): Promise<BootstrapInfo>;
|
|
162
|
+
/**
|
|
163
|
+
* Resolve a CMS Resource ID from a legacy dataset (content system) ID.
|
|
164
|
+
* Maps to: GET /v1/cms/dataset/:datasetId
|
|
165
|
+
*
|
|
166
|
+
* Used during upgrade migration to convert old FIGMA_CONTENT_API_CONTENT_SYSTEM_ID
|
|
167
|
+
* into the new FIGMA_PROJECT_ID (CMS Resource ID).
|
|
168
|
+
*/
|
|
169
|
+
export declare function getCmsResourceId(credential: AuthCredential, datasetId: string): Promise<string>;
|
|
124
170
|
//# 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 process.env.FIGMA_API_BASE_URL ||
|
|
11
|
+
return process.env.FIGMA_API_BASE_URL || 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,54 @@ 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
|
+
}
|
|
177
187
|
// REAL API IMPLEMENTATION
|
|
178
|
-
const response = await
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
188
|
+
const response = await controlPlaneFetch({
|
|
189
|
+
context: 'create deployment',
|
|
190
|
+
options: {
|
|
191
|
+
body: JSON.stringify({
|
|
192
|
+
pages,
|
|
193
|
+
static_assets: options.staticAssets
|
|
194
|
+
}),
|
|
195
|
+
headers: {
|
|
196
|
+
...getAuthHeaders(credential),
|
|
197
|
+
'Content-Type': 'application/json'
|
|
198
|
+
},
|
|
199
|
+
method: 'POST'
|
|
185
200
|
},
|
|
186
|
-
|
|
201
|
+
url
|
|
187
202
|
});
|
|
188
|
-
if (!response.ok) {
|
|
189
|
-
throw new ControlPlaneError(`Failed to create deployment: ${response.status} ${response.statusText}`, response.status);
|
|
190
|
-
}
|
|
191
203
|
const data = await response.json();
|
|
192
204
|
// Map API response format to our interface
|
|
193
205
|
return {
|
|
194
|
-
codeUploadUrl: data.meta.
|
|
206
|
+
codeUploadUrl: data.meta.lambda_zip_upload_url,
|
|
195
207
|
deploymentId: data.meta.deployment_id,
|
|
208
|
+
pageUploadUrls: data.meta.page_upload_urls,
|
|
196
209
|
staticAssetUploadUrls: data.meta.static_asset_upload_urls
|
|
197
210
|
};
|
|
198
211
|
}
|
|
@@ -204,37 +217,126 @@ import * as log from '../utils/log.js';
|
|
|
204
217
|
* @param tenantId - Tenant ID
|
|
205
218
|
* @param options - Deployment perform options
|
|
206
219
|
* @returns Deployment status and message
|
|
207
|
-
*/ export async function performDeployment(
|
|
208
|
-
|
|
209
|
-
const shouldMock = process.env.FIGMA_MOCK_CONTROL_PLANE !== 'false';
|
|
220
|
+
*/ export async function performDeployment(credential, tenantId, options) {
|
|
221
|
+
const shouldMock = process.env.FIGMA_MOCK_CONTROL_PLANE === 'true';
|
|
210
222
|
if (shouldMock) {
|
|
211
223
|
// MOCK IMPLEMENTATION: Return mock deployment status
|
|
212
224
|
log.debug('Using mock Control Plane API for performDeployment (FIGMA_MOCK_CONTROL_PLANE != "false")');
|
|
213
225
|
return {
|
|
214
226
|
deploymentId: options.deploymentId,
|
|
215
|
-
message: 'Deployment initiated successfully'
|
|
227
|
+
message: 'Deployment initiated successfully',
|
|
228
|
+
tenantDomains: [
|
|
229
|
+
'example.figmasource.site'
|
|
230
|
+
]
|
|
216
231
|
};
|
|
217
232
|
}
|
|
233
|
+
const url = `${getControlPlaneBaseUrl()}/v1/cms/tenant/${tenantId}/deploy/perform`;
|
|
234
|
+
log.debug(`Calling performDeployment API at ${url}`);
|
|
218
235
|
// REAL API IMPLEMENTATION
|
|
219
|
-
const response = await
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
236
|
+
const response = await controlPlaneFetch({
|
|
237
|
+
context: 'perform deployment',
|
|
238
|
+
options: {
|
|
239
|
+
body: JSON.stringify({
|
|
240
|
+
deployment_id: options.deploymentId
|
|
241
|
+
}),
|
|
242
|
+
headers: {
|
|
243
|
+
...getAuthHeaders(credential),
|
|
244
|
+
'Content-Type': 'application/json'
|
|
245
|
+
},
|
|
246
|
+
method: 'POST'
|
|
226
247
|
},
|
|
227
|
-
|
|
248
|
+
url
|
|
228
249
|
});
|
|
229
|
-
if (!response.ok) {
|
|
230
|
-
throw new ControlPlaneError(`Failed to perform deployment: ${response.status} ${response.statusText}`, response.status);
|
|
231
|
-
}
|
|
232
250
|
const data = await response.json();
|
|
233
251
|
// Map API response to our interface
|
|
234
252
|
return {
|
|
235
253
|
deploymentId: data.meta.deployment_id,
|
|
236
|
-
message: data.meta.message || 'Deployment initiated'
|
|
254
|
+
message: data.meta.message || 'Deployment initiated',
|
|
255
|
+
tenantDomains: data.meta.tenant_domains
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Get bootstrap info for a CMS resource
|
|
260
|
+
* Maps to: GET /v1/cms/:cmsResourceId/bootstrap
|
|
261
|
+
*
|
|
262
|
+
* @param accessToken - OAuth access token
|
|
263
|
+
* @param cmsResourceId - CMS Resource ID (project ID)
|
|
264
|
+
* @param environmentName - Optional environment name filter
|
|
265
|
+
*/ export async function getBootstrapInfo(credential, cmsResourceId, environmentName) {
|
|
266
|
+
const baseUrl = getControlPlaneBaseUrl();
|
|
267
|
+
let url = `${baseUrl}/v1/cms/${cmsResourceId}/bootstrap`;
|
|
268
|
+
if (environmentName) {
|
|
269
|
+
url += `?environment_name=${encodeURIComponent(environmentName)}`;
|
|
270
|
+
}
|
|
271
|
+
log.debug(`Calling getBootstrapInfo API at ${url}`);
|
|
272
|
+
const response = await controlPlaneFetch({
|
|
273
|
+
context: 'get bootstrap info',
|
|
274
|
+
options: {
|
|
275
|
+
headers: getAuthHeaders(credential)
|
|
276
|
+
},
|
|
277
|
+
url
|
|
278
|
+
});
|
|
279
|
+
const data = await response.json();
|
|
280
|
+
return {
|
|
281
|
+
environments: data.meta.environments.map((env)=>({
|
|
282
|
+
name: env.name,
|
|
283
|
+
contentSystemId: env.content_system_id,
|
|
284
|
+
tenantInstanceId: env.tenant_instance_id
|
|
285
|
+
})),
|
|
286
|
+
oauthCredentials: {
|
|
287
|
+
oauthClientId: data.meta.oauth_credentials.oauth_client_id,
|
|
288
|
+
oauthClientSecret: data.meta.oauth_credentials.oauth_client_secret
|
|
289
|
+
}
|
|
237
290
|
};
|
|
238
291
|
}
|
|
292
|
+
/**
|
|
293
|
+
* Resolve a CMS Resource ID from a legacy dataset (content system) ID.
|
|
294
|
+
* Maps to: GET /v1/cms/dataset/:datasetId
|
|
295
|
+
*
|
|
296
|
+
* Used during upgrade migration to convert old FIGMA_CONTENT_API_CONTENT_SYSTEM_ID
|
|
297
|
+
* into the new FIGMA_PROJECT_ID (CMS Resource ID).
|
|
298
|
+
*/ export async function getCmsResourceId(credential, datasetId) {
|
|
299
|
+
const url = `${getControlPlaneBaseUrl()}/v1/cms/dataset/${datasetId}`;
|
|
300
|
+
log.debug(`Calling getCmsResourceId API at ${url}`);
|
|
301
|
+
const response = await controlPlaneFetch({
|
|
302
|
+
context: 'get CMS resource ID from dataset',
|
|
303
|
+
options: {
|
|
304
|
+
headers: getAuthHeaders(credential)
|
|
305
|
+
},
|
|
306
|
+
url
|
|
307
|
+
});
|
|
308
|
+
const data = await response.json();
|
|
309
|
+
return data.meta.cms_resource_id;
|
|
310
|
+
}
|
|
311
|
+
const MAX_RETRIES = 3;
|
|
312
|
+
const INITIAL_RETRY_DELAY = 1000;
|
|
313
|
+
function sleep(ms) {
|
|
314
|
+
return new Promise((resolve)=>setTimeout(resolve, ms));
|
|
315
|
+
}
|
|
316
|
+
async function controlPlaneFetch(params) {
|
|
317
|
+
const { context, options, url } = params;
|
|
318
|
+
let lastError;
|
|
319
|
+
for(let attempt = 0; attempt < MAX_RETRIES; attempt++){
|
|
320
|
+
try {
|
|
321
|
+
const response = await fetch(url, options);
|
|
322
|
+
if (response.ok) {
|
|
323
|
+
return response;
|
|
324
|
+
}
|
|
325
|
+
if (response.status < 500) {
|
|
326
|
+
throw new ControlPlaneError(`Failed to ${context}: ${response.status} ${response.statusText}`, response.status);
|
|
327
|
+
}
|
|
328
|
+
lastError = new ControlPlaneError(`Failed to ${context}: ${response.status} ${response.statusText}`, response.status);
|
|
329
|
+
} catch (error) {
|
|
330
|
+
if (error instanceof ControlPlaneError) {
|
|
331
|
+
throw error;
|
|
332
|
+
}
|
|
333
|
+
lastError = error instanceof Error ? error : new Error('Unknown error');
|
|
334
|
+
}
|
|
335
|
+
if (attempt < MAX_RETRIES - 1) {
|
|
336
|
+
await sleep(INITIAL_RETRY_DELAY * Math.pow(2, attempt));
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
throw new ControlPlaneError(`Network error while ${context}: ${lastError?.message || 'Unknown error'}`, undefined, lastError);
|
|
340
|
+
}
|
|
239
341
|
|
|
240
342
|
//# 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
|
package/dist/api/figma-api.js
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Client for Figma REST API (Pixie) endpoints
|
|
5
5
|
* Handles project token generation and other CMS-related API calls
|
|
6
|
-
*/ import
|
|
6
|
+
*/ import { getAuthHeaders } from '../auth/credentials.js';
|
|
7
|
+
import { getEnvConfig } from '../constants.js';
|
|
8
|
+
import * as log from '../utils/log.js';
|
|
7
9
|
/**
|
|
8
10
|
* Error thrown when Figma API calls fail
|
|
9
11
|
*/ export class FigmaApiError extends Error {
|
|
@@ -14,19 +16,6 @@
|
|
|
14
16
|
this.name = 'FigmaApiError';
|
|
15
17
|
}
|
|
16
18
|
}
|
|
17
|
-
/**
|
|
18
|
-
* Base URLs for Figma API
|
|
19
|
-
*/ const API_BASE_URLS = {
|
|
20
|
-
prod: 'https://api.figma.com',
|
|
21
|
-
staging: 'https://api.staging.figma.com'
|
|
22
|
-
};
|
|
23
|
-
/**
|
|
24
|
-
* Get the Figma API base URL based on environment
|
|
25
|
-
* TODO: Use this once real API endpoints are available
|
|
26
|
-
*/ function _getApiBaseUrl() {
|
|
27
|
-
// For now, default to staging to match OAuth config
|
|
28
|
-
return process.env.FIGMA_API_BASE_URL || API_BASE_URLS.staging;
|
|
29
|
-
}
|
|
30
19
|
/**
|
|
31
20
|
* Get a project token (JWT) for a specific tenant/CMS
|
|
32
21
|
*
|
|
@@ -40,14 +29,42 @@
|
|
|
40
29
|
* @param tenantId - The tenant/CMS ID
|
|
41
30
|
* @returns ProjectToken with JWT and expiry information
|
|
42
31
|
* @throws {FigmaApiError} If the API call fails
|
|
43
|
-
*/ export async function getProjectToken(
|
|
44
|
-
// Check
|
|
45
|
-
|
|
46
|
-
|
|
32
|
+
*/ export async function getProjectToken(credential, tenantId) {
|
|
33
|
+
// Priority 1: Check for direct token value from environment
|
|
34
|
+
const envTokenValue = process.env.FIGMA_MOCK_PROJECT_TOKEN_VALUE;
|
|
35
|
+
if (envTokenValue) {
|
|
36
|
+
log.debug('Using direct project token from FIGMA_MOCK_PROJECT_TOKEN_VALUE');
|
|
37
|
+
try {
|
|
38
|
+
// Parse JWT payload to extract claims
|
|
39
|
+
const parts = envTokenValue.split('.');
|
|
40
|
+
if (parts.length !== 3) {
|
|
41
|
+
throw new Error('Invalid JWT format: must have 3 parts (header.payload.signature)');
|
|
42
|
+
}
|
|
43
|
+
const payload = parts[1];
|
|
44
|
+
const base64 = payload.replace(/-/g, '+').replace(/_/g, '/');
|
|
45
|
+
const paddedBase64 = base64.padEnd(base64.length + (4 - base64.length % 4) % 4, '=');
|
|
46
|
+
const decodedPayload = JSON.parse(Buffer.from(paddedBase64, 'base64').toString('utf-8'));
|
|
47
|
+
if (!decodedPayload.exp || typeof decodedPayload.exp !== 'number') {
|
|
48
|
+
throw new Error('JWT payload missing exp claim');
|
|
49
|
+
}
|
|
50
|
+
// Extract tenant ID from aud claim (use parameter as fallback)
|
|
51
|
+
const extractedTenantId = decodedPayload.aud || tenantId;
|
|
52
|
+
return {
|
|
53
|
+
expiresAt: decodedPayload.exp * 1000,
|
|
54
|
+
tenantId: extractedTenantId,
|
|
55
|
+
token: envTokenValue
|
|
56
|
+
};
|
|
57
|
+
} catch (error) {
|
|
58
|
+
throw new FigmaApiError(`Invalid JWT token in FIGMA_MOCK_PROJECT_TOKEN_VALUE: ${error instanceof Error ? error.message : 'Unknown error'}`, undefined, error instanceof Error ? error : undefined);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
// Priority 2: Check if project token API should be mocked
|
|
62
|
+
// Default to false (use real API)
|
|
63
|
+
const shouldMock = process.env.FIGMA_MOCK_PROJECT_TOKEN === 'true';
|
|
47
64
|
try {
|
|
48
65
|
if (shouldMock) {
|
|
49
66
|
// MOCK IMPLEMENTATION: Generate a mock JWT token for testing
|
|
50
|
-
log.debug('Using mock project token API for getProjectToken (FIGMA_MOCK_PROJECT_TOKEN
|
|
67
|
+
log.debug('Using mock project token API for getProjectToken (FIGMA_MOCK_PROJECT_TOKEN = "true")');
|
|
51
68
|
const mockToken = createMockJWT(tenantId, 25) // 25 minutes expiry
|
|
52
69
|
;
|
|
53
70
|
// Mock response data
|
|
@@ -68,12 +85,10 @@
|
|
|
68
85
|
};
|
|
69
86
|
}
|
|
70
87
|
// REAL API IMPLEMENTATION
|
|
71
|
-
const baseUrl =
|
|
88
|
+
const baseUrl = process.env.FIGMA_API_BASE_URL || getEnvConfig().apiBaseUrl;
|
|
72
89
|
const url = `${baseUrl}/v1/cms/${tenantId}/token/`;
|
|
73
90
|
const response = await fetch(url, {
|
|
74
|
-
headers:
|
|
75
|
-
Authorization: `Bearer ${accessToken}`
|
|
76
|
-
},
|
|
91
|
+
headers: getAuthHeaders(credential),
|
|
77
92
|
method: 'POST'
|
|
78
93
|
});
|
|
79
94
|
if (!response.ok) {
|
|
@@ -81,12 +96,19 @@
|
|
|
81
96
|
let errorMessage = `Failed to get project token: ${response.status} ${response.statusText}`;
|
|
82
97
|
try {
|
|
83
98
|
const errorBody = await response.json();
|
|
84
|
-
|
|
85
|
-
|
|
99
|
+
// Only use string error messages (API may return { error: true })
|
|
100
|
+
if (typeof errorBody.message === 'string') {
|
|
101
|
+
errorMessage = errorBody.message;
|
|
102
|
+
} else if (typeof errorBody.error === 'string') {
|
|
103
|
+
errorMessage = errorBody.error;
|
|
86
104
|
}
|
|
87
105
|
} catch {
|
|
88
106
|
// Ignore JSON parse errors for error body
|
|
89
107
|
}
|
|
108
|
+
// Provide actionable error for common cases
|
|
109
|
+
if (response.status === 404) {
|
|
110
|
+
errorMessage = `Content System ID "${tenantId}" not found. Ensure FIGMA_CONTENT_API_CONTENT_SYSTEM_ID is set to a valid content system ID in your .env file.`;
|
|
111
|
+
}
|
|
90
112
|
throw new FigmaApiError(errorMessage, response.status);
|
|
91
113
|
}
|
|
92
114
|
const data = await response.json();
|
|
@@ -165,5 +187,36 @@
|
|
|
165
187
|
throw new FigmaApiError(`Failed to parse JWT expiry: ${error instanceof Error ? error.message : 'Unknown error'}`, undefined, error instanceof Error ? error : undefined);
|
|
166
188
|
}
|
|
167
189
|
}
|
|
190
|
+
/**
|
|
191
|
+
* Get user info from Figma API
|
|
192
|
+
*
|
|
193
|
+
* Endpoint: GET https://api.figma.com/v1/me
|
|
194
|
+
* Requires OAuth access_token (not project token)
|
|
195
|
+
*
|
|
196
|
+
* @param accessToken - OAuth access token for authentication
|
|
197
|
+
* @returns FigmaUserInfo with user profile data
|
|
198
|
+
* @throws {FigmaApiError} If the API call fails
|
|
199
|
+
*/ export async function getUserInfo(credential) {
|
|
200
|
+
const baseUrl = process.env.FIGMA_API_BASE_URL || getEnvConfig().apiBaseUrl;
|
|
201
|
+
const url = `${baseUrl}/v1/me`;
|
|
202
|
+
try {
|
|
203
|
+
const response = await fetch(url, {
|
|
204
|
+
headers: getAuthHeaders(credential)
|
|
205
|
+
});
|
|
206
|
+
if (!response.ok) {
|
|
207
|
+
throw new FigmaApiError(`Failed to get user info: ${response.status} ${response.statusText}`, response.status);
|
|
208
|
+
}
|
|
209
|
+
const data = await response.json();
|
|
210
|
+
if (!data.id || !data.email || typeof data.handle !== 'string') {
|
|
211
|
+
throw new FigmaApiError('Invalid user info response: missing required fields');
|
|
212
|
+
}
|
|
213
|
+
return data;
|
|
214
|
+
} catch (error) {
|
|
215
|
+
if (error instanceof FigmaApiError) {
|
|
216
|
+
throw error;
|
|
217
|
+
}
|
|
218
|
+
throw new FigmaApiError(`Failed to get user info: ${error instanceof Error ? error.message : 'Unknown error'}`, undefined, error instanceof Error ? error : undefined);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
168
221
|
|
|
169
222
|
//# sourceMappingURL=figma-api.js.map
|