Selegic CRM Docs
ServerExtensions

Publish Flow

How extension bundles are packaged, validated, and deployed to private GCS.

The publish flow takes a built extension bundle and deploys it to Selegic securely.

Flow Overview

valid invalid Build extension scrm extension publish Validate slug, version, size CRM Server Upload to GCS Create audit log Version ready Reject with error

Steps

  1. Build: Build extension with Vite or similar
  2. Validate: CLI validates slug, version, bundle size
  3. Upload: Server uploads assets to private GCS
  4. Audit: Create audit log record

Usage

# From extension package directory
cd examples/vacation-trip
pnpm build
scrm extension publish --tenant acme-corp

Dry Run

Validate without uploading:

scrm extension publish --tenant acme-corp --dry-run

Package Metadata

Extensions can declare defaults in package.json:

{
  "selegic": {
    "extension": {
      "slug": "vacation-trip",
      "bundlePath": "dist",
      "manifest": "manifest.json",
      "name": "Vacation Trip Manager",
      "description": "Plan vacation trips"
    }
  }
}

Environment Variables

CLI

VariableDescription
SCRM_SERVER_URLCRM server base URL
SCRM_TENANT_IDTenant slug (or --tenant)
SCRM_API_KEYAPI key for auth

Server

VariableDescription
EXTENSION_GCS_BUCKETPrivate bucket name
EXTENSION_GCS_PROJECT_IDGCP project ID
EXTENSION_GCS_KEY_FILEService account key
GCS_EMULATOR_HOSTLocal emulator
EXTENSION_TOKEN_SECRETToken signing secret

CLI Behavior

  • Requires --tenant or SCRM_TENANT_ID
  • Rejects unsafe slugs and non-semver versions
  • Filters dotfiles and hidden paths
  • Computes SHA-256 checksum
  • Supports --dry-run

Server Behavior

  • Validates upload shape and file limits
  • Rejects duplicate extension_id + version (immutable)
  • Stores assets in private GCS
  • Creates audit log record

Local Development

# 1. Start GCS emulator
docker compose up gcs-emulator

# 2. Set env variables
export GCS_EMULATOR_HOST="localhost:8080"
export EXTENSION_GCS_BUCKET="extensions-dev"

# 3. Build and publish
cd examples/vacation-trip
pnpm build
scrm extension publish --tenant local-dev

Troubleshooting

400 on Publish

  • Cause: Invalid slug, version, file path, or checksum
  • Fix: Re-run with --dry-run and fix issues

409 on Publish

  • Cause: Version already exists (versions are immutable)
  • Fix: Publish a new semver version

Checksum Mismatch

  • Cause: Bundle changed after checksum computed
  • Fix: Rebuild and re-run CLI

404 on Assets After Publish

  • Cause: Installation inactive or path mismatch
  • Fix: Verify installation active and path correct

On this page