Skip to content

Commit

Permalink
initialDataTypes: Add RawInitialData and start populating.
Browse files Browse the repository at this point in the history
Greg points out [1] that it's time we start keeping track of a type
for our initial data pre-transformation, since we're about to start
transforming it.

Here, start very small by saying what we expect `realm_users` and
two of its friends to look like. We grab those expectations from the
`avatar_url` field on `User` and on `CrossRealmBot`.

[1] #4230 (comment)
  • Loading branch information
chrisbobbe committed Nov 3, 2020
1 parent a1f51e4 commit b21053f
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/api/initialDataTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,14 @@ export type InitialDataRealmFilters = {|
realm_filters: RealmFilter[],
|};

// TODO: Make complete and exact.
export type RawInitialDataRealmUser = {
realm_users: Array<{| ...User, avatar_url: string | null |}>,
realm_non_active_users: Array<{| ...User, avatar_url: string | null |}>,
cross_realm_bots: Array<{| ...CrossRealmBot, avatar_url: string | void | null |}>,
...
};

export type InitialDataRealmUser = {|
avatar_source: 'G',
avatar_url: string | null,
Expand Down Expand Up @@ -280,7 +288,17 @@ export type InitialDataUserStatus = {|
user_status?: UserStatusMapObject,
|};

// Initial data snapshot sent in response to a `/register` request.
// Initial data snapshot sent in response to a `/register` request,
// before validation and transformation.
//
// TODO: Make complete and exact.
export type RawInitialData = {
...RawInitialDataRealmUser,
...
};

// Initial data snapshot sent in response to a `/register` request,
// after validation and transformation.
export type InitialData = {|
// The server sends different subsets of the full available data,
// depending on what event types the client subscribes to with the
Expand Down

0 comments on commit b21053f

Please sign in to comment.