AppMage

Static Site Editor

This endpoint group provides methods for managing and editing static site content, including media overrides, text overrides, and triggering site rebuilds. It also offers a way to check user permissions for editing.

Endpoints

POST /api/rpc (Method: StaticSiteEditorRpc.saveMedia)

  • Description: Saves a media (image/video) override from a Base64 string. Delegates to StaticSiteEditorService.

  • Request Body:

    {
      "method": "StaticSiteEditorRpc.saveMedia",
      "params": {
        "siteName": "my-site",
        "mediaName": "hero-image",
        "base64Data": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="
      }
    }
  • Parameters:

    Name Type Required Description
    siteName String Yes The name of the static site to which the media override applies.
    mediaName String Yes The logical name of the media being overridden (e.g., "hero-image").
    base64Data String Yes The Base64 encoded string of the media, including the data URI prefix (e.g., data:image/png;base64,...).
  • Response:

    {
      "success": true,
      "data": {
        "success": true,
        "path": "/path/to/saved/media/override.png"
      }
    }
  • Example (cURL):

    curl -X POST https://api.example.com/api/rpc \
      -H "Content-Type: application/json" \
      -H "X-API-Key: YOUR_API_KEY" \
      -d '{
        "method": "StaticSiteEditorRpc.saveMedia",
        "params": {
          "siteName": "my-site",
          "mediaName": "hero-image",
          "base64Data": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="
        }
      }'

POST /api/rpc (Method: StaticSiteEditorRpc.saveText)

  • Description: Saves a batch of text overrides. Delegates to StaticSiteEditorService.

  • Request Body:

    {
      "method": "StaticSiteEditorRpc.saveText",
      "params": {
        "siteName": "my-site",
        "overrides": {
          "welcome_message": "Welcome to our updated site!",
          "contact_email": "[email protected]"
        }
      }
    }
  • Parameters:

    Name Type Required Description
    siteName String Yes The name of the static site to which the text overrides apply.
    overrides Object Yes A JSON object where keys are the text override keys and values are the new text strings.
  • Response:

    {
      "success": true,
      "data": {
        "success": true,
        "path": "/path/to/saved/text-overrides.json"
      }
    }
  • Example (cURL):

    curl -X POST https://api.example.com/api/rpc \
      -H "Content-Type: application/json" \
      -H "X-API-Key: YOUR_API_KEY" \
      -d '{
        "method": "StaticSiteEditorRpc.saveText",
        "params": {
          "siteName": "my-site",
          "overrides": {
            "welcome_message": "Welcome to our updated site!",
            "contact_email": "[email protected]"
          }
        }
      }'

POST /api/rpc (Method: StaticSiteEditorRpc.rebuildSite)

  • Description: Triggers a rebuild of a specific static site and returns a job ID for polling. The actual build process is handled by a command executed by StaticSiteManagerService.

  • Request Body:

    {
      "method": "StaticSiteEditorRpc.rebuildSite",
      "params": {
        "siteName": "my-site"
      }
    }
  • Parameters:

    Name Type Required Description
    siteName String Yes The name of the static site to rebuild.
  • Response:

    {
      "success": true,
      "data": {
        "success": true,
        "jobId": "rebuild-my-site-1678886400000",
        "message": "Rebuild process for site 'my-site' has been initiated."
      }
    }
  • Example (cURL):

    curl -X POST https://api.example.com/api/rpc \
      -H "Content-Type: application/json" \
      -H "X-API-Key: YOUR_API_KEY" \
      -d '{
        "method": "StaticSiteEditorRpc.rebuildSite",
        "params": {
          "siteName": "my-site"
        }
      }'

POST /api/rpc (Method: StaticSiteEditorRpc.getRebuildStatus)

  • Description: Gets the status of a static site rebuild job. The job status is managed by StaticSiteManagerService.

  • Request Body:

    {
      "method": "StaticSiteEditorRpc.getRebuildStatus",
      "params": {
        "jobId": "rebuild-my-site-1678886400000"
      }
    }
  • Parameters:

    Name Type Required Description
    jobId String Yes The ID of the rebuild job to check.
  • Response:

    {
      "success": true,
      "data": {
        "status": "pending"
      }
    }

    or

    {
      "success": true,
      "data": {
        "status": "completed",
        "siteName": "my-site",
        "startTime": 1678886400000,
        "endTime": 1678886410000,
        "message": "Site 'my-site' rebuilt successfully."
      }
    }

    or

    {
      "success": true,
      "data": {
        "status": "failed",
        "siteName": "my-site",
        "startTime": 1678886400000,
        "endTime": 1678886410000,
        "error": "Error details here."
      }
    }

    or

    {
      "success": true,
      "data": {
        "status": "not_found"
      }
    }
  • Example (cURL):

    curl -X POST https://api.example.com/api/rpc \
      -H "Content-Type: application/json" \
      -H "X-API-Key: YOUR_API_KEY" \
      -d '{
        "method": "StaticSiteEditorRpc.getRebuildStatus",
        "params": {
          "jobId": "rebuild-my-site-1678886400000"
        }
      }'

POST /api/rpc (Method: StaticSiteEditorRpc.revertMedia)

  • Description: Reverts a media override, causing the site to fall back to the original. Delegates to StaticSiteEditorService.

  • Request Body:

    {
      "method": "StaticSiteEditorRpc.revertMedia",
      "params": {
        "siteName": "my-site",
        "mediaName": "hero-image"
      }
    }
  • Parameters:

    Name Type Required Description
    siteName String Yes The name of the static site from which to revert the media override.
    mediaName String Yes The logical name of the media override to revert.
  • Response:

    {
      "success": true,
      "data": {
        "success": true,
        "message": "Media override reverted successfully."
      }
    }
  • **Example (cURL):

    curl -X POST https://api.example.com/api/rpc \
      -H "Content-Type: application/json" \
      -H "X-API-Key: YOUR_API_KEY" \
      -d '{
        "method": "StaticSiteEditorRpc.revertMedia",
        "params": {
          "siteName": "my-site",
          "mediaName": "hero-image"
        }
      }'

POST /api/rpc (Method: StaticSiteEditorRpc.revertText)

  • Description: Reverts a text override for a specific key. Delegates to StaticSiteEditorService.

  • Request Body:

    {
      "method": "StaticSiteEditorRpc.revertText",
      "params": {
        "siteName": "my-site",
        "textKey": "welcome_message"
      }
    }
  • Parameters:

    Name Type Required Description
    siteName String Yes The name of the static site from which to revert the text override.
    textKey String Yes The key of the text override to revert.
  • Response:

    {
      "success": true,
      "data": {
        "success": true,
        "message": "Text override reverted successfully."
      }
    }
  • Example (cURL):

    curl -X POST https://api.example.com/api/rpc \
      -H "Content-Type: application/json" \
      -H "X-API-Key: YOUR_API_KEY" \
      -d '{
        "method": "StaticSiteEditorRpc.revertText",
        "params": {
          "siteName": "my-site",
          "textKey": "welcome_message"
        }
      }'

POST /api/rpc (Method: StaticSiteEditorRpc.canEdit)

  • Description: Checks if the current user is allowed to edit the specified static site. This method considers both the user's role and the site's configuration. It checks if the context.user.role is 'admin' and if the site's allowEditing configuration is true via StaticSiteManagerService.

  • Request Body:

    {
      "method": "StaticSiteEditorRpc.canEdit",
      "params": {
        "siteName": "my-site"
      }
    }
  • Parameters:

    Name Type Required Description
    siteName String Yes The name of the static site to check editing permissions for.
  • Response:

    {
      "success": true,
      "data": {
        "canEdit": true
      }
    }

    or

    {
      "success": true,
      "data": {
        "canEdit": false
      }
    }
  • Example (cURL):

    curl -X POST https://api.example.com/api/rpc \
      -H "Content-Type: application/json" \
      -H "X-API-Key: YOUR_API_KEY" \
      -d '{
        "method": "StaticSiteEditorRpc.canEdit",
        "params": {
          "siteName": "my-site"
        }
      }'