trellis
Version:
Agentic State Engine — event-sourced causal graph with branching, decision traces, and realtime sync for AI-native applications
49 lines (47 loc) • 1.33 kB
JavaScript
// src/server/deploy-meta.ts
var DEPLOY_NAME_RE = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;
var MIN_LEN = 3;
var MAX_LEN = 32;
var DeployNameError = class extends Error {
constructor(message) {
super(message);
this.name = "DeployNameError";
}
};
function normalizeDeployName(name) {
return name.trim().toLowerCase();
}
function validateDeployName(name) {
const normalized = normalizeDeployName(name);
if (!normalized) {
throw new DeployNameError("Deploy name is required.");
}
if (normalized.length < MIN_LEN || normalized.length > MAX_LEN) {
throw new DeployNameError(
`Deploy name must be ${MIN_LEN}\u2013${MAX_LEN} characters (got ${normalized.length}).`
);
}
if (normalized.includes("--")) {
throw new DeployNameError(
"Deploy name cannot contain consecutive hyphens."
);
}
if (!DEPLOY_NAME_RE.test(normalized)) {
throw new DeployNameError(
"Deploy name must start with a letter and use only lowercase letters, numbers, and single hyphens (e.g. my-app)."
);
}
return normalized;
}
function buildDeployUrl(name) {
const slug = validateDeployName(name);
return `https://${slug}.sprites.app`;
}
var SPRITE_PUBLIC_HTTP_PORT = 8080;
export {
DeployNameError,
normalizeDeployName,
validateDeployName,
buildDeployUrl,
SPRITE_PUBLIC_HTTP_PORT
};