Add batch.exec(callables, timeout=10) — a general-purpose concurrent execution primitive that runs arbitrary Starlark callables in parallel, each in its own thread with independent step budget. Enables extensions to fan out library function calls (frozen exports from lib.require) without decomposing them back into raw http.post parameters. New permission: batch.exec. Max 8 callables, timeout 1-30s. Nesting prohibited via atomic flag. 12 new tests, all pass with -race. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
69 lines
2.4 KiB
Go
69 lines
2.4 KiB
Go
package models
|
|
|
|
import "time"
|
|
|
|
// ── Package Status Constants ─────────────────
|
|
|
|
const (
|
|
// PackageStatusActive means the package is running normally.
|
|
PackageStatusActive = "active"
|
|
|
|
// PackageStatusPendingReview means the package declared permissions
|
|
// that require admin approval before activation.
|
|
PackageStatusPendingReview = "pending_review"
|
|
|
|
// PackageStatusSuspended means an admin has suspended the package.
|
|
PackageStatusSuspended = "suspended"
|
|
)
|
|
|
|
// ValidPackageStatuses is the set of valid package status values.
|
|
var ValidPackageStatuses = map[string]bool{
|
|
PackageStatusActive: true,
|
|
PackageStatusPendingReview: true,
|
|
PackageStatusSuspended: true,
|
|
}
|
|
|
|
// ── Extension Permission Constants ───────────
|
|
|
|
const (
|
|
ExtPermSecretsRead = "secrets.read"
|
|
ExtPermNotificationsSend = "notifications.send"
|
|
ExtPermDBRead = "db.read"
|
|
ExtPermDBWrite = "db.write"
|
|
ExtPermAPIHTTP = "api.http"
|
|
ExtPermFormValidate = "forms.validate"
|
|
ExtPermWorkflowAccess = "workflow.access"
|
|
ExtPermConnectionsRead = "connections.read"
|
|
ExtPermTriggersRegister = "triggers.register"
|
|
ExtPermRealtimePublish = "realtime.publish"
|
|
ExtPermBatchExec = "batch.exec"
|
|
)
|
|
|
|
// ValidExtensionPermissions is the set of recognized permission keys.
|
|
var ValidExtensionPermissions = map[string]bool{
|
|
ExtPermSecretsRead: true,
|
|
ExtPermNotificationsSend: true,
|
|
ExtPermDBRead: true,
|
|
ExtPermDBWrite: true,
|
|
ExtPermAPIHTTP: true,
|
|
ExtPermFormValidate: true,
|
|
ExtPermWorkflowAccess: true,
|
|
ExtPermConnectionsRead: true,
|
|
ExtPermTriggersRegister: true,
|
|
ExtPermRealtimePublish: true,
|
|
ExtPermBatchExec: true,
|
|
}
|
|
|
|
// ── Extension Permission Model ───────────────
|
|
|
|
// ExtensionPermission represents a declared/granted capability for a package.
|
|
type ExtensionPermission struct {
|
|
ID string `json:"id" db:"id"`
|
|
PackageID string `json:"package_id" db:"package_id"`
|
|
Permission string `json:"permission" db:"permission"`
|
|
Granted bool `json:"granted" db:"granted"`
|
|
GrantedBy *string `json:"granted_by,omitempty" db:"granted_by"`
|
|
GrantedAt *time.Time `json:"granted_at,omitempty" db:"granted_at"`
|
|
CreatedAt time.Time `json:"created_at" db:"created_at"`
|
|
}
|