Files
wotra/internal/collections/collections.go
T
aksdb 73359d3f39 ♻️ Answer unknown API routes with JSON and fix stale comments
The SPA catch-all answered unknown /api paths with the index page and
status 200, so the client SDK failed to parse the body. A catch-all per
HTTP method answers them with a JSON 404 in the error shape of
PocketBase; the routes registered before keep precedence. The comment
on DataFields no longer claims the fields of the read-only collections
were client writable.
2026-12-01 16:59:19 +01:00

26 lines
1.2 KiB
Go

package collections
import "slices"
var Synced = []string{"entries", "closed_days", "closed_weeks", "settings_history", "balance_adjustments"}
// ReadOnly collections are pulled by clients but only ever written by the server.
var ReadOnly = []string{"closed_days", "closed_weeks"}
// DataFields lists, per synced collection, the record fields that hold the data
// of a row, in contrast to the sync fields every collection shares (owner, rev,
// client_updated_at and deleted). Only the fields of the writable collections
// reach the records through the push endpoint; the read-only collections are
// written by the server alone.
var DataFields = map[string][]string{
"entries": {"start_time", "end_time", "auto_stopped", "note", "day_key"},
"closed_days": {"day_key", "worked_ms", "kind", "closed_at"},
"closed_weeks": {"week_key", "expected_ms", "worked_ms", "delta_ms", "closed_at"},
"settings_history": {"effective_from", "hours_per_week", "workdays_mask", "timezone"},
"balance_adjustments": {"delta_ms", "note", "effective_at"},
}
func IsSynced(name string) bool { return slices.Contains(Synced, name) }
func IsReadOnly(name string) bool { return slices.Contains(ReadOnly, name) }