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
Steps
- Build: Build extension with Vite or similar
- Validate: CLI validates slug, version, bundle size
- Upload: Server uploads assets to private GCS
- Audit: Create audit log record
Usage
# From extension package directory
cd examples/vacation-trip
pnpm build
scrm extension publish --tenant acme-corpDry Run
Validate without uploading:
scrm extension publish --tenant acme-corp --dry-runPackage 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
| Variable | Description |
|---|---|
SCRM_SERVER_URL | CRM server base URL |
SCRM_TENANT_ID | Tenant slug (or --tenant) |
SCRM_API_KEY | API key for auth |
Server
| Variable | Description |
|---|---|
EXTENSION_GCS_BUCKET | Private bucket name |
EXTENSION_GCS_PROJECT_ID | GCP project ID |
EXTENSION_GCS_KEY_FILE | Service account key |
GCS_EMULATOR_HOST | Local emulator |
EXTENSION_TOKEN_SECRET | Token signing secret |
CLI Behavior
- Requires
--tenantorSCRM_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-devTroubleshooting
400 on Publish
- Cause: Invalid slug, version, file path, or checksum
- Fix: Re-run with
--dry-runand 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