コンテンツにスキップ

Code2Des Result 取得

メソッド

この API は WF2Des/Code2WF と同じ control-plane/data-plane separation に従います。

HTTP メソッド

GET: Completed Code2Des native-Figma artifact を取得

命名規則

Response は worker-owned artifact の snake_case を維持します。Image node には、元の artifact field を変更・削除せず、backend が asset.data_base64 を追加します。

リクエストとレスポンス

ヘッダー

リクエストヘッダー

  • Authorization
  • Accept
  • Accept-language

レスポンスヘッダー

  • Content-Type

Code2Des Result 取得

URI

GET /api/v1/organizations/{organization_id}/projects/{project_id}/code2des/{code2des_id}/result

パスパラメータ

名前 型 必須 説明
organization_id integer 必須 Organization ID
project_id integer 必須 Project ID
code2des_id string 必須 Code2Des UUID

リクエストボディ

なし。

レスポンス

Response は JSON(HTTP status: 200 OK)です。

{
  "code2des_id": "019ffa75-01c0-75a2-8123-456789abcdf0",
  "page_import_id": "019ffa75-01c0-75a2-8123-456789abcdef",
  "status": "succeeded",
  "capture_hash": "sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "spec": {
    "spec_version": "1.0",
    "mode": "exact",
    "viewport": {
      "width": 1440,
      "height": 900,
      "device_scale_factor": 1
    },
    "source_url": "https://example.com/",
    "screenshot_url": "s3://bucket/1/7/page-import/page-id/screenshot.png",
    "screenshot_hash": "sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
    "font_faces": [],
    "root": {
      "node": "frame",
      "layer_path": "root",
      "name": "example.com",
      "bbox": { "x": 0, "y": 0, "w": 1440, "h": 900 },
      "opacity": 1,
      "absolute": true,
      "source_node_id": "root",
      "source_tag": "body",
      "fills": [],
      "border": null,
      "corner_radius": [0, 0, 0, 0],
      "effects": [],
      "clips_content": false,
      "blend_mode": "normal",
      "layout_hint": {
        "mode": "none",
        "gap": 0,
        "counter_gap": 0,
        "wrap": false,
        "padding": [0, 0, 0, 0],
        "primary_align": "MIN",
        "counter_align": "MIN"
      },
      "children": []
    },
    "warnings": []
  }
}

レスポンスフィールド

名前 型 説明
code2des_id string この artifact を生成した Code2Des job。
page_import_id string Source Page Import identity。
status string 成功 artifact は常に "succeeded"。
capture_hash string Worker が使用した Page Import capture exact bytes の SHA-256 identity。
spec object Viewport/source evidence、font evidence、root node tree、warning を持つ deterministic native-Figma specification。
spec.root object Root frame。Descendant は frame、text、image、vector、unmatched。
image.asset.data_base64 string Plugin materialization 用に backend が注入する image bytes。Hydrate 済み image node に存在。

Status と分離する理由

GET .../code2des/{code2des_id} は小さい PostgreSQL lifecycle row だけを読み、繰り返し poll できます。この result endpoint は、resultUrl の download、spec.root の parse/validation、全 image asset の exact tenant/Page Import prefix 検証、image object の download、base64 bytes の注入という、より高コストな data-plane 処理を行います。

分離により、status polling のたびに大きくなり得る artifact と asset を download することを防ぎます。Result source が二つあるわけではありません。Status response の resultUrl は metadata のみで、この endpoint が result content を返します。

認証

Amazon Cognito JWT で認証し、project の Read access が必要です。

エラーハンドリング

説明 Status Code Status 名
Authentication credential がない 401 Unauthorized
Job が missing/scope 外/soft-deleted/processing/failed、または result pointer がない 404 Not Found
Artifact が malformed、または image reference が tenant-scoped Page Import asset prefix 外 500 Internal Server Error

処理フロー

  1. Authenticate し、Read access を検証します。
  2. Scope 内かつ non-deleted の Code2Des lifecycle row を取得します。
  3. status: "1" と non-null resultUrl を要求します。
  4. S3 から immutable JSON artifact を download/parse します。
  5. spec.root を要求し、tenant-scoped image node に asset.data_base64 を hydrate します。
  6. Materialization state を変更せず artifact を返します。

Plugin が Figma root を作成した後、その side effect は POST .../code2des/{code2des_id}/placement で別に記録します。