Other Structures

The following structures are available globally.

  • Prune Old Event Forums

    In long-lived Swiftarr instances such as the Beta, we typically do not reset the database between sailings. As we accumulate years of events, the amount of forums starts to grow unweildy. The old events are marked as deleted and removed from the schedule, but the forums remain. This backend command is intended to be executed by an operator in one of these long-lived environments to soft-delete all forums that are linked to soft-deleted events.

    The effects of this command can be reversed by importing the deleted schedule again which will restore the events and their associated forums (thanks, soft-delete).

    See more

    Declaration

    Swift

    struct PruneEventForumsCommand : AsyncCommand
  • Declaration

    Swift

    struct GenerateScheduleCommand : AsyncCommand
  • Random number generator that can be initialized with a seed value. Copied from https://github.com/mattgallagher/CwlUtils/blob/master/Sources/CwlUtils/CwlRandom.swift

    The idea here is that this RNG is seeded with a user’s userID, and will always produce the same sequence of numbers when building a user’s identicon..

    See more

    Declaration

    Swift

    public struct Xoshiro : RandomNumberGenerator
  • Declaration

    Swift

    struct SongInfoJSON : Decodable
  • The collection of /api/v3/performer/* route endpoints and handler functions related to the official performers and shadow event organizers..

    See more

    Declaration

    Swift

    struct PerformerController : APIRouteCollection
  • The collection of /api/v3/personalevents/* route endpoints and handler functions related to events that are specific to individual users.

    See more

    Declaration

    Swift

    struct PersonalEventController : APIRouteCollection
  • Used during bulk import of User information. Reports the result of merging the new User data into the database, or for the Verify operation, previews what that result will be.Purposefully does not report specific regCodes that are in conflict.

    The idea behind this struct is to split out cases where we might get 1000+ errors under certain import conditions, so we don’t just return an array of Errors where there’s one important error buried in a thousand ‘duplicate name and regcode’ errors.

    See more

    Declaration

    Swift

    public struct BulkUserUpdateVerificationData : Content
  • For admins to upload new daily themes, or edit existing ones.

    See more

    Declaration

    Swift

    public struct DailyThemeUploadData : Content
  • Used to validate changes to the Event database. This public struct shows the differrences between the current schedule and the (already uploaded but not processed) updated schedule. Event identity is based on the uid field–two events with the same uid are the same event, and if they show different times, we conclude the event’s time changed. Two events with different uids are different events, even if all other fields are exactly the same.

    Events that are added or deleted will only appear in deleted or created event arrays. Modified events could appear in any or all of the 3 modification arrays. Deleted events take their contents from the database. All other arrays take content from the update.

    Required by: POST /api/v3/admin/schedule/verify

    See EventController.eventsUpdateHandler(_:data:).

    See more

    Declaration

    Swift

    public struct EventUpdateDifferenceData : Content
  • Declaration

    Swift

    public struct EventUpdateLogData : Content
  • Used to report what the results of applying an update to the Event-Performer pivots is going to do. The uploaded source information is an Excel spreadsheet containing all the published events, with information on which official performers (if any) will be performing at each event.

    When uploading a new performer links spreadsheet, it’s important that both Events and Performers are fully updated first. This operation doesn’t create performers or events, just links them with a pivot.

    Returned by: POST /api/v3/admin/schedule/verify

    See more

    Declaration

    Swift

    public struct EventPerformerValidationData : Content
  • Returns the registration code associated with a user. Not all users have registration codes; e.g. asking for the reg code for ‘admin’ will return an error.

    See more

    Declaration

    Swift

    public struct RegistrationCodeUserData : Content
  • Returns general info about registration codes.

    Each passenger gets sent an email with a unique registration code; the reg code allows them to create verified accounts. This struct lets the admins quickly view some basic stats on account usage.

    See more

    Declaration

    Swift

    public struct RegistrationCodeStatsData : Content
  • The Bulk User Download file is a serialization of this object, plus a bunch of image files, all zipped up.

    See more

    Declaration

    Swift

    public struct SaveRestoreData : Content
  • An array of totals for various database entities. Each value in the array is essentially a SQL SELECT COUNT() FROM <table>, although some values apply filters to the counted rows.

    The CountType enum defines what each value in the counts array means, so counts[0] is a count of the Users in the database.

    Used by: GET /api/v3/admin/rollup

    See more

    Declaration

    Swift

    struct ServerRollupData : Content
  • Used to enable/disable features. A featurePair with name: “kraken” and feature: “schedule” indicates the Schedule feature of the Kraken app. When the server indicates this app:feature pair is disabled, the client app should not show the feature to users, and should avoid calling API calls related to that feature. Either the app or feature field could be ‘all’.

    Used in: SettingsAdminData, SettingsUpdateData

    See more

    Declaration

    Swift

    public struct SettingsAppFeaturePair : Content
  • Used to return the current Settings values.

    Required by: GET /api/v3/events/update

    See AdminController.settingsHandler().

    See more

    Declaration

    Swift

    public struct SettingsAdminData : Content
  • Used to update the Settings values. Doesn’t update everything–some values aren’t meant to be updated live. The updated values are saved so that they’ll persist through app launches. Any optional values set to nil are not used to update Settings values.

    Required by: POST /api/v3/events/update

    See AdminController.settingsUpdateHandler().

    See more

    Declaration

    Swift

    public struct SettingsUpdateData : Content
  • Used to return information about the time zone changes scheduled to occur during the cruise.

    Returned by: GET /api/v3/admin/timezonechanges

    See more

    Declaration

    Swift

    public struct TimeZoneChangeData : Content
  • Used to bulk save/restore user accounts. This was created to allow us to download an archive of all registered users from the staging server just before embarkation, and then load the archived users onto the prod server as soon as we get on the boat.

    Just archiving Users directly would work, but using a DTO gives us better control in the case of schema changes between staging and prod, or if we need to massage the data to get the restore to work correctly. Also, this method tries whenever possible to put data from related tables we want to save/restore right in the User object; otherwise we’d have to export RegistrationCode and EventFavorite(and maybe a bunch of other tables) and match everything up as part of import.

    Also: This DTO contains sensitive data and should only be used for Admin routes.

    See more

    Declaration

    Swift

    struct UserSaveRestoreData : Content
  • Parameters for the game recommender engine. Pass these values in, get back a BoardgameResponseData with a list of games filtered to match the criteria, and sorted based on how well they match the criteria. The sort takes into account each games’ overall rating from BGG, the recommended number of players (not just min and max allowed players), the average playtime, and the complexity score of the game.

    Sent to these methods as the JSON request body:

    • GET /api/v3/boardgames/recommend
    See more

    Declaration

    Swift

    public struct BoardgameRecommendationData : Content
  • Used to return the day’s theme.

    Returned by: GET /api/v3/notifications/dailythemes

    See more

    Declaration

    Swift

    public struct DailyThemeData : Content
  • A feature that has been turned off by the server. If the appName is all, the indicated featureName is disabled at the API level for this feature and all relevant endpoints will return errors. For any other value of appName, the API still works, but the indicated client apps should not allow the feature to be accessed. The goal is to be able to disable code that is impacting server stability or performance without shutting down the server entirely or disallowing specific clients entirely.

    Used in UserNotificationData.

    See more

    Declaration

    Swift

    public struct DisabledFeature : Content
  • All errors returned in HTTP responses use this structure.

    Some server errors (such as 404s) may not have any payload in the response body, but for any HTTP error response that has a payload, the payload will have this strcture.

    error is always true, reason concatenates all errors into a single string, and fieldErrors breaks errors up by field name of the request’s body content, if available. Only content validation errors actaully use fieldErrors. Field-specific validation errors are keyed by the path to the field that caused the error. Validation errors that aren’t specific to an input field (e.g. an error indicating that one of two fields may be empty, but not both) are all concatenated and placed into a general key in fieldErrors. This means that all field errors are both in error (concatenated into a single string), and also in fieldErrors (split into fields).

    Note

    If the request body has validation errors, the error response should list all validation errors at once. However, other errors that may prevent a successful action will not be included. For instance, a user might try creating a Forum with empty fields. The error response will indicate that both Title and Text fields need values. After fixing those issues, the user could still get an error becuase they are quarantined and not authorized to create posts.
    See more

    Declaration

    Swift

    public struct ErrorResponse : Codable, Error
  • Used to return data on a group of FriendlyFez objects.

    See more

    Declaration

    Swift

    public struct FezListData : Content
  • Used to return a (partial) list of forums along with the number of forums in the found set. Similar to CategoryData, but the forums need not be from the same category. Instead, this returns forums that match a common attribute acoss all categores.

    Returned by:

    • GET /api/v3/forum/favorites
    • GET /api/v3/forum/owner

    See ForumController.categoriesHandler(_:)

    See more

    Declaration

    Swift

    public struct ForumSearchData : Content
  • Wraps an array of KaraokeSongData with information for pagination. KaraokeSongData returns data about a single song.

    Returned by: GET /api/v3/karaoke See KaraokeController.getKaraokeSongs().

    See more

    Declaration

    Swift

    public struct KaraokeSongResponseData : Content
  • Returns information about a song in the Karaoke Song Library.

    Returned by: GET /api/v3/karaoke/:song_id Incorporated into: KaraokeSongResponseData

    See more

    Declaration

    Swift

    public struct KaraokeSongData : Content
  • Returns information about songs that have been performed in the Karaoke Lounge onboard.

    Returned by: GET /api/v3/karaoke/performance Incorporated into: KaraokeSongData, which itself is incorporated into KaraokeSongResponseData

    See more

    Declaration

    Swift

    public struct KaraokePerformedSongsData : Content
  • Returns information about songs that have been performed in the Karaoke Lounge onboard.

    Returned by: GET /api/v3/karaoke/performance Incorporated into: KaraokeSongData, which itself is incorporated into `KaraokeSongResponseData

    See more

    Declaration

    Swift

    public struct KaraokePerformedSongsResult : Content
  • Used to obtain the user’s current list of alert or mute keywords.

    Returned by:

    • GET /api/v3/user/alertwords
    • POST /api/v3/user/alertwords/add/STRING
    • POST /api/v3/user/alertwords/remove/STRING
    • GET /api/v3/user/mutewords
    • POST /api/v3/user/mutewords/add/STRING
    • POST /api/v3/user/mutewords/remove/STRING

    See UserController.alertwordsHandler(_:), UserController.alertwordsAddHandler(_:), UserController.alertwordsRemoveHandler(_:).

    See more

    Declaration

    Swift

    public struct KeywordData : Content
  • Used to return a list of completed Micro Karaoke songs, that is, finished videos the user can watch.

    Returned by:

    • GET /api/v3/karaoke/mk/songlist

    See UsersController.headerHandler(_:), ClientController.userHeadersHandler(_:).

    See more

    Declaration

    Swift

    public struct MicroKaraokeCompletedSong : Content
  • Used to upload a Micro Karaoke video. The offerID comes from the server when it offers a song clip.

    Used by:

    • POST /api/v3/karaoke/mk/recording
    See more

    Declaration

    Swift

    public struct MicroKaraokeRecordingData : Content
  • Declaration

    Swift

    public struct MicroKaraokeSnippetModeration : Content
  • When a user starts the Micro Karaoke flow to sing and record part of a song, the server reserves a song slot for that user and returns into about their reservation, including the lyrics they should sing, what song it’s part of, and URLs for the vocal and no-vocal song clipe.

    Returned by:

    • POST /api/v3/karaoke/mk/offer
    See more

    Declaration

    Swift

    public struct MicroKaraokeOfferPacket : Content
  • Declaration

    Swift

    public struct MicroKaraokeSongManifest : Content
  • Composes into other structs to add pagination.

    Generally this will be added to a top-level struct along with an array of some result type, like this:

        struct SomeCollectionData: Content {
            var paginator: Paginator
            var collection: [CollectionElementType]
        }
    

    The Paginator lets you page through results, showing the total number of pages and the current page. The outer-level struct should document the sort ordering for the returned collection; the first element in the sorted collection is returned in the first result element when start = 0.

    In many cases the size of the returned array will be smaller than limit, and not only at the end of the results. In several cases the results may be filtered after the database query returns. The next ‘page’ of results should be calculated with start + limit, not with start + collection.count.

    See more

    Declaration

    Swift

    public struct Paginator : Content
  • This simple generic lets us declare route result types as Paginated<ContentType>, where ContentType is an array of some Content struct (probably found in this file). This simplifies writing paginated reults as we don’t need to create a separate struct just to hold the paginator, but it may make the structs more opaque, especially to those that don’t know Swift. Part of the idea of this file was to make it easy for developers to understand the JSON that would be emitted by these structs.

    See more

    Declaration

    Swift

    public struct Paginated<ResultClass> : Content
  • Returns info about a single Performer. This header information is similar to the UserHeader structure, containing just enough info to build a title card for a performer.

    This structure is also used to break the recusion cycle where a PerformerData contains a list of Events, and the Events contain lists of the Performers that will be there. In this case, the Event has an array of PerformerHeaderData instead of PerformerData.

    Incorporated into PerformerData Incorporated into EventData

    See more

    Declaration

    Swift

    public struct PerformerHeaderData : Content
  • Returns info about a single perfomer. Most fields are optional, and the array fields may be empty, although they shouldn’t be under normal conditions.

    Returned by: GET /api/v3/performer/self Returned by: GET /api/v3/performer/:performer_id

    See more

    Declaration

    Swift

    public struct PerformerData : Content
  • Wraps up a list of performers with pagination info.

    Returned by:GET /api/v3/performer/official Returned by:GET /api/v3/performer/shadow

    See more

    Declaration

    Swift

    public struct PerformerResponseData : Content
  • Used to create and update Performer models.

    Used by: POST /api/v3/performer/forEvent/:event_id Used by: POST /api/v3/performer/official/add

    See more

    Declaration

    Swift

    public struct PerformerUploadData : Content
  • Returns info about a single Photo from the Photostream.

    Incorporated into PhotostreamListData, which is returned by: GET /api/v3/photostream

    See more

    Declaration

    Swift

    struct PhotostreamImageData : Content
  • Returns paginated data on photos in the photo stream. Non-Mods should only have access to the most recent photos, with no pagination. However: /api/v3/photostream returns one of thse objects even for non-mod users–it just returns 30 photos and sets paginator.total to 30.

    Returned by: GET /api/v3/photostream

    See more

    Declaration

    Swift

    struct PhotostreamListData : Content
  • Returns information on available tags to use when tagging a photo to be uploaded to the photostream. A photo may be tagged with an event or with a generic ship location. Calling api/v3/photostream/placenames fills the events parameter with information about events that are currently happening. When a photo is uploaded, its tag is validated, and validation will fail if the tagged event has ended.

    Returned by: GET /api/v3/photostream

    See more

    Declaration

    Swift

    struct PhotostreamLocationData : Content
  • Uploads a photo to the photostream. Either the eventID or the locationName must be set.

    Sent in request body to: POST /api/v3/photostream/upload.

    See more

    Declaration

    Swift

    struct PhotostreamUploadData : Content
  • Used to return info about a search for ForumPosts. Like forums, this returns an array of PostData. However, this gives the results of a search for posts across all the forums.

    Returned by: GET /api/v3/forum/post/search

    See more

    Declaration

    Swift

    public struct PostSearchData : Content
  • A bool, wrapped in a struct. Used for the results of user capability queries.

    Required by:

    • POST /api/v3/karaoke/userIsManager

    See UserController.createHandler(_:data:), UserController.addHandler(_:data:).

    See more

    Declaration

    Swift

    public struct UserAuthorizedToCreateKaraokeLogs : Content
  • Returns status about a single Alertword, for either Twarrts of ForumPost hits on that word. Used inside UserNotificationData.

    See more

    Declaration

    Swift

    public struct UserNotificationAlertwordData : Content
  • Provides updates about server global state and the logged in user’s notifications. userNotificationHandler() is intended to be called frequently by clients (I mean, don’t call it once a second).

    Returned by AlertController.userNotificationHandler()

    See more

    Declaration

    Swift

    public struct UserNotificationData : Content
  • Used to edit the current user’s profile contents. For profile data on users, see ProfilePublicData.

    Required by:

    • POST /api/v3/user/profile

    Returned by:

    • GET /api/v3/user/profile
    • POST /api/v3/user/profile

    See UserController.profileHandler(_:), UserController.profileUpdateHandler(_:data:).

    See more

    Declaration

    Swift

    public struct UserProfileUploadData : Content
    extension UserProfileUploadData: RCFValidatable

Username Validation

Personal Events

Concrete LibGd Formatter

Hexadecimal

ModelAuthenticatable Conformance