Documentation
¶
Overview ¶
Package youngutil contains the small amount of transport and date handling shared by Young catalog and workspace commands.
Index ¶
- Constants
- Variables
- func DateRange(view DateView, anchor string, now time.Time) (string, string, error)
- func FetchAllIfUnpaged(ctx context.Context, fetch func(context.Context, url.Values) (any, error), ...) (any, error)
- func FetchAllPages(ctx context.Context, fetch func(context.Context, url.Values) (any, error), ...) (any, error)
- func PageParams(page, limit int) (url.Values, error)
- func PathID(base, id string) string
- func RequireID(value, flag string) (string, error)
- type DateView
Constants ¶
const ( EventsPath = "/api/catalog/young-events" OrganizersPath = "/api/catalog/young-organizers" YoungEventSubscriptionsPath = "/api/workspace/young-event-subscriptions" YoungOrganizerSubscriptionsPath = "/api/workspace/young-organizer-subscriptions" YoungNotificationsPath = "/api/workspace/young-notifications" PersonalCalendarEventsPath = "/api/workspace/calendar/events" )
Variables ¶
var Shanghai = time.FixedZone("Asia/Shanghai", 8*60*60)
Functions ¶
func DateRange ¶
DateRange returns inclusive Shanghai calendar-date bounds for an anchor. An empty anchor means today in Asia/Shanghai.
func FetchAllIfUnpaged ¶
func FetchAllIfUnpaged( ctx context.Context, fetch func(context.Context, url.Values) (any, error), path string, params url.Values, key string, pageSize int, identityKey string, ) (any, error)
FetchAllIfUnpaged follows every page when the caller did not explicitly select a page or page size. Explicit pagination remains server-side so the command can be used for bounded scripts as well as complete interactive listings.
func FetchAllPages ¶
func FetchAllPages( ctx context.Context, fetch func(context.Context, url.Values) (any, error), path string, params url.Values, key string, pageSize int, identityKey string, ) (any, error)
FetchAllPages reads every page of a standard {data, pagination} response. The returned response is rewritten as one complete page so table, JSON and jq output all describe the same result.
func PageParams ¶
PageParams validates CLI pagination flags and maps --limit to pageSize.