Page MenuHomePhorge

D7467.1765103083.diff
No OneTemporary

Size
28 KB
Referenced Files
None
Subscribers
None

D7467.1765103083.diff

diff --git a/keyserver/src/responders/activity-responders.js b/keyserver/src/responders/activity-responders.js
--- a/keyserver/src/responders/activity-responders.js
+++ b/keyserver/src/responders/activity-responders.js
@@ -1,13 +1,14 @@
// @flow
import t from 'tcomb';
-import type { TList, TInterface } from 'tcomb';
+import type { TList } from 'tcomb';
import type {
UpdateActivityResult,
UpdateActivityRequest,
SetThreadUnreadStatusRequest,
SetThreadUnreadStatusResult,
+ ActivityUpdate,
} from 'lib/types/activity-types.js';
import { tShape } from 'lib/utils/validation-utils.js';
@@ -18,7 +19,7 @@
} from '../updaters/activity-updaters.js';
import { validateInput } from '../utils/validation-utils.js';
-const activityUpdatesInputValidator: TList<TInterface> = t.list(
+const activityUpdatesInputValidator: TList<Array<ActivityUpdate>> = t.list(
tShape({
focus: t.Bool,
threadID: t.String,
diff --git a/keyserver/src/responders/device-responders.js b/keyserver/src/responders/device-responders.js
--- a/keyserver/src/responders/device-responders.js
+++ b/keyserver/src/responders/device-responders.js
@@ -10,11 +10,12 @@
import { deviceTokenUpdater } from '../updaters/device-token-updaters.js';
import { validateInput } from '../utils/validation-utils.js';
-const deviceTokenUpdateRequestInputValidator: TInterface = tShape({
- deviceToken: t.maybe(t.String),
- deviceType: t.maybe(t.enums.of(['ios', 'android'])),
- platformDetails: t.maybe(tPlatformDetails),
-});
+const deviceTokenUpdateRequestInputValidator: TInterface<DeviceTokenUpdateRequest> =
+ tShape({
+ deviceToken: t.maybe(t.String),
+ deviceType: t.maybe(t.enums.of(['ios', 'android'])),
+ platformDetails: t.maybe(tPlatformDetails),
+ });
async function deviceTokenUpdateResponder(
viewer: Viewer,
diff --git a/keyserver/src/responders/entry-responders.js b/keyserver/src/responders/entry-responders.js
--- a/keyserver/src/responders/entry-responders.js
+++ b/keyserver/src/responders/entry-responders.js
@@ -16,7 +16,10 @@
DeltaEntryInfosResult,
SaveEntryResponse,
} from 'lib/types/entry-types.js';
-import { calendarThreadFilterTypes } from 'lib/types/filter-types.js';
+import {
+ type CalendarFilter,
+ calendarThreadFilterTypes,
+} from 'lib/types/filter-types.js';
import type {
FetchEntryRevisionInfosResult,
FetchEntryRevisionInfosRequest,
@@ -40,7 +43,14 @@
import { commitSessionUpdate } from '../updaters/session-updaters.js';
import { validateInput } from '../utils/validation-utils.js';
-const entryQueryInputValidator: TInterface = tShape({
+type EntryQueryInput = {
+ +startDate: string,
+ +endDate: string,
+ +navID?: ?string,
+ +includeDeleted?: ?boolean,
+ +filters?: ?$ReadOnlyArray<CalendarFilter>,
+};
+const entryQueryInputValidator: TInterface<EntryQueryInput> = tShape({
navID: t.maybe(t.String),
startDate: tDate,
endDate: tDate,
@@ -59,7 +69,8 @@
),
),
});
-const newEntryQueryInputValidator: TInterface = tShape({
+
+const newEntryQueryInputValidator: TInterface<CalendarQuery> = tShape({
startDate: tDate,
endDate: tDate,
filters: t.list(
diff --git a/keyserver/src/responders/report-responders.js b/keyserver/src/responders/report-responders.js
--- a/keyserver/src/responders/report-responders.js
+++ b/keyserver/src/responders/report-responders.js
@@ -9,6 +9,8 @@
type ReportCreationRequest,
type FetchErrorReportInfosResponse,
type FetchErrorReportInfosRequest,
+ type ThreadInconsistencyReportShape,
+ type EntryInconsistencyReportShape,
reportTypes,
} from 'lib/types/report-types.js';
import { ServerError } from 'lib/utils/errors.js';
@@ -32,27 +34,29 @@
time: t.Number,
summary: t.String,
});
-const threadInconsistencyReportValidatorShape: TStructProps = {
- platformDetails: tPlatformDetails,
- beforeAction: t.Object,
- action: t.Object,
- pollResult: t.maybe(t.Object),
- pushResult: t.Object,
- lastActionTypes: t.maybe(t.list(t.String)),
- lastActions: t.maybe(t.list(tActionSummary)),
- time: t.maybe(t.Number),
-};
-const entryInconsistencyReportValidatorShape: TStructProps = {
- platformDetails: tPlatformDetails,
- beforeAction: t.Object,
- action: t.Object,
- calendarQuery: newEntryQueryInputValidator,
- pollResult: t.maybe(t.Object),
- pushResult: t.Object,
- lastActionTypes: t.maybe(t.list(t.String)),
- lastActions: t.maybe(t.list(tActionSummary)),
- time: t.Number,
-};
+const threadInconsistencyReportValidatorShape: TStructProps<ThreadInconsistencyReportShape> =
+ {
+ platformDetails: tPlatformDetails,
+ beforeAction: t.Object,
+ action: t.Object,
+ pollResult: t.maybe(t.Object),
+ pushResult: t.Object,
+ lastActionTypes: t.maybe(t.list(t.String)),
+ lastActions: t.maybe(t.list(tActionSummary)),
+ time: t.maybe(t.Number),
+ };
+const entryInconsistencyReportValidatorShape: TStructProps<EntryInconsistencyReportShape> =
+ {
+ platformDetails: tPlatformDetails,
+ beforeAction: t.Object,
+ action: t.Object,
+ calendarQuery: newEntryQueryInputValidator,
+ pollResult: t.maybe(t.Object),
+ pushResult: t.Object,
+ lastActionTypes: t.maybe(t.list(t.String)),
+ lastActions: t.maybe(t.list(tActionSummary)),
+ time: t.Number,
+ };
const userInconsistencyReportValidatorShape = {
platformDetails: tPlatformDetails,
action: t.Object,
diff --git a/keyserver/src/responders/thread-responders.js b/keyserver/src/responders/thread-responders.js
--- a/keyserver/src/responders/thread-responders.js
+++ b/keyserver/src/responders/thread-responders.js
@@ -1,7 +1,7 @@
// @flow
import t from 'tcomb';
-import type { TUnion, TInterface } from 'tcomb';
+import type { TUnion } from 'tcomb';
import {
type ThreadDeletionRequest,
@@ -138,7 +138,7 @@
initialMemberIDs: t.maybe(t.list(t.String)),
calendarQuery: t.maybe(entryQueryInputValidator),
};
-const newThreadRequestInputValidator: TUnion<TInterface> = t.union([
+const newThreadRequestInputValidator: TUnion<ServerNewThreadRequest> = t.union([
tShape({
type: tNumEnum([threadTypes.SIDEBAR]),
sourceMessageID: t.String,
diff --git a/keyserver/src/socket/session-utils.js b/keyserver/src/socket/session-utils.js
--- a/keyserver/src/socket/session-utils.js
+++ b/keyserver/src/socket/session-utils.js
@@ -2,7 +2,7 @@
import invariant from 'invariant';
import t from 'tcomb';
-import type { TUnion, TInterface } from 'tcomb';
+import type { TUnion } from 'tcomb';
import {
usersInRawEntryInfos,
@@ -74,7 +74,7 @@
import type { SessionUpdate } from '../updaters/session-updaters.js';
import { getOlmUtility } from '../utils/olm-utils.js';
-const clientResponseInputValidator: TUnion<TInterface> = t.union([
+const clientResponseInputValidator: TUnion<ClientResponse> = t.union([
tShape({
type: t.irreducible(
'serverRequestTypes.PLATFORM',
diff --git a/lib/flow-typed/npm/tcomb_v3.x.x.js b/lib/flow-typed/npm/tcomb_v3.x.x.js
--- a/lib/flow-typed/npm/tcomb_v3.x.x.js
+++ b/lib/flow-typed/npm/tcomb_v3.x.x.js
@@ -2,532 +2,135 @@
// flow-typed version: <<STUB>>/tcomb_v3.2.29/flow_v0.137.0
declare module 'tcomb' {
- declare type TBaseMeta = {
- +kind: string,
- +name: string,
- +identity: boolean,
- ...
- };
-
- declare export class TType<T, M = TBaseMeta> {
+ declare class TBaseType<+T> {
(val: T): this;
is(val: mixed): boolean;
displayName: string;
- meta: M;
- t: T;
+ +t: T;
}
- declare export class TIrreducible<T> extends TType<T, {|
- +kind: string,
- +name: string,
- +identity: boolean,
- +predicate: mixed => boolean,
- |}> { }
-
- declare export class TMaybe<T> extends TType<void | T, {|
- +kind: string,
- +name: string,
- +identity: boolean,
- +type: TType<T>,
- |}> { }
-
- declare export class TList<T> extends TType<Array<T>, {|
- +kind: string,
- +name: string,
- +identity: boolean,
- +type: TType<T>,
- |}> { }
-
- declare export class TDict<T> extends TType<{ [key: string]: T }, {|
- +kind: string,
- +name: string,
- +identity: boolean,
- +domain: TType<string>,
- +codomain: T,
- |}> { }
+ declare export type TType<+T> =
+ | TIrreducible<T>
+ | TMaybe<T>
+ | TList<T>
+ | TDict<T>
+ | TUnion<T>
+ | TEnums
+ | TRefinement<T>
+ | TInterface<T>;
+
+ declare export class TIrreducible<+T> extends TBaseType<T> {
+ meta: {
+ +kind: 'irreducible',
+ +name: string,
+ +identity: boolean,
+ +predicate: mixed => boolean,
+ }
+ }
+
+ declare export class TMaybe<+T> extends TBaseType<T> {
+ meta: {
+ +kind: 'maybe',
+ +name: string,
+ +identity: boolean,
+ +type: TType<T>,
+ }
+ }
+
+ declare export class TList<+T> extends TBaseType<T> {
+ meta: {
+ +kind: 'list',
+ +name: string,
+ +identity: boolean,
+ +type: TType<T>,
+ }
+ }
+
+ declare export class TDict<+T> extends TBaseType<T> {
+ meta: {
+ +kind: 'dict',
+ +name: string,
+ +identity: boolean,
+ +domain: TType<string>,
+ +codomain: TType<T>,
+ }
+ }
+
+ declare export class TUnion<+T> extends TBaseType<T> {
+ meta: {
+ +kind: 'union',
+ +name: string,
+ +identity: boolean,
+ +types: Array<TType<T>>,
+ }
+ }
- declare export class TUnion<T> extends TType<T, {|
- +kind: string,
- +name: string,
- +identity: boolean,
- +types: Array<TType<T>>,
- |}> { }
+ declare export class TEnums extends TBaseType<string> {
+ meta: {
+ +kind: 'enums',
+ +name: string,
+ +identity: boolean,
+ +map: Object,
+ }
+ }
- declare export class TEnums extends TType<string, {|
- +kind: string,
- +name: string,
- +identity: boolean,
- +map: Object,
- |}> { }
+ declare export class TRefinement<+T> extends TBaseType<T> {
+ meta: {
+ +kind: 'subtype',
+ +name: string,
+ +identity: boolean,
+ +type: TType<T>,
+ +predicate: mixed => boolean,
+ }
+ }
- declare export class TRefinement<T> extends TType<T, {|
- +kind: string,
- +name: string,
- +identity: boolean,
- +type: TType<T>,
- +predicate: mixed => boolean,
- |}> { }
+ declare type TypeToValidator = <V>(v: V) => TType<V>;
- declare export type TStructProps = { [key: string]: TType<any, any> };
+ declare export type TStructProps<+T> = $ObjMap<T, TypeToValidator>;
declare type TStructOptions = {|
name?: string,
strict?: boolean,
defaultProps?: Object,
|};
- declare export class TInterface extends TType<any, {|
- +kind: string,
- +name: string,
- +identity: boolean,
- +props: TStructProps,
- +strict: boolean,
- |}> { }
+
+ declare export class TInterface<+T> extends TBaseType<T> {
+ meta: {|
+ +kind: 'interface',
+ +name: string,
+ +identity: boolean,
+ +props: TStructProps<T>,
+ +strict: boolean,
+ |}
+ }
declare export default {
+ +Nil: TIrreducible<void | null>,
+Bool: TIrreducible<boolean>,
+Boolean: TIrreducible<boolean>,
+String: TIrreducible<string>,
+Number: TIrreducible<number>,
+Object: TIrreducible<Object>,
- maybe<T, M>(type: TType<T, M>, name?: string): TMaybe<T>,
- list<T, M>(type: TType<T, M>, name?: string): TList<T>,
- dict<T, M1, M2>(
- domain: TType<string, M1>,
- codomain: TType<T, M2>,
+ maybe<T>(type: TType<T>, name?: string): TMaybe<void | T>,
+ list<T>(type: TType<T>, name?: string): TList<Array<T>>,
+ dict<T>(
+ domain: TType<string>,
+ codomain: TType<T>,
name?: string,
- ): TDict<T>,
- union<T, M>(types: Array<TType<T, M>>, name?: string): TUnion<T>,
+ ): TDict<{ [key: string]: T }>,
+ union<+T>(types: $ReadOnlyArray<TType<T>>, name?: string): TUnion<T>,
+enums: {|
of(enums: $ReadOnlyArray<string>, name?: string): TEnums,
|},
irreducible<T>(name: string, predicate: mixed => boolean): TIrreducible<T>,
- refinement<T, M>(
- type: TType<T, M>,
+ refinement<T>(
+ type: TType<T>,
predicate: T => boolean,
name?: string,
): TRefinement<T>,
- interface(
- props: TStructProps,
+ interface<T>(
+ props: TStructProps<T>,
options?: string | TStructOptions,
- ): TInterface,
+ ): TInterface<T>,
...
};
}
-
-/**
- * We include stubs for each file inside this npm package in case you need to
- * require those files directly. Feel free to delete any files that aren't
- * needed.
- */
-declare module 'tcomb/lib/Any' {
- declare module.exports: any;
-}
-
-declare module 'tcomb/lib/Array' {
- declare module.exports: any;
-}
-
-declare module 'tcomb/lib/assert' {
- declare module.exports: any;
-}
-
-declare module 'tcomb/lib/assign' {
- declare module.exports: any;
-}
-
-declare module 'tcomb/lib/Boolean' {
- declare module.exports: any;
-}
-
-declare module 'tcomb/lib/create' {
- declare module.exports: any;
-}
-
-declare module 'tcomb/lib/Date' {
- declare module.exports: any;
-}
-
-declare module 'tcomb/lib/declare' {
- declare module.exports: any;
-}
-
-declare module 'tcomb/lib/decompose' {
- declare module.exports: any;
-}
-
-declare module 'tcomb/lib/dict' {
- declare module.exports: any;
-}
-
-declare module 'tcomb/lib/enums' {
- declare module.exports: any;
-}
-
-declare module 'tcomb/lib/Error' {
- declare module.exports: any;
-}
-
-declare module 'tcomb/lib/extend' {
- declare module.exports: any;
-}
-
-declare module 'tcomb/lib/fail' {
- declare module.exports: any;
-}
-
-declare module 'tcomb/lib/forbidNewOperator' {
- declare module.exports: any;
-}
-
-declare module 'tcomb/lib/fromJSON' {
- declare module.exports: any;
-}
-
-declare module 'tcomb/lib/func' {
- declare module.exports: any;
-}
-
-declare module 'tcomb/lib/Function' {
- declare module.exports: any;
-}
-
-declare module 'tcomb/lib/getDefaultInterfaceName' {
- declare module.exports: any;
-}
-
-declare module 'tcomb/lib/getFunctionName' {
- declare module.exports: any;
-}
-
-declare module 'tcomb/lib/getTypeName' {
- declare module.exports: any;
-}
-
-declare module 'tcomb/lib/installTypeFormatter' {
- declare module.exports: any;
-}
-
-declare module 'tcomb/lib/Integer' {
- declare module.exports: any;
-}
-
-declare module 'tcomb/lib/interface' {
- declare module.exports: any;
-}
-
-declare module 'tcomb/lib/intersection' {
- declare module.exports: any;
-}
-
-declare module 'tcomb/lib/irreducible' {
- declare module.exports: any;
-}
-
-declare module 'tcomb/lib/is' {
- declare module.exports: any;
-}
-
-declare module 'tcomb/lib/isArray' {
- declare module.exports: any;
-}
-
-declare module 'tcomb/lib/isBoolean' {
- declare module.exports: any;
-}
-
-declare module 'tcomb/lib/isFunction' {
- declare module.exports: any;
-}
-
-declare module 'tcomb/lib/isIdentity' {
- declare module.exports: any;
-}
-
-declare module 'tcomb/lib/isInterface' {
- declare module.exports: any;
-}
-
-declare module 'tcomb/lib/isMaybe' {
- declare module.exports: any;
-}
-
-declare module 'tcomb/lib/isNil' {
- declare module.exports: any;
-}
-
-declare module 'tcomb/lib/isNumber' {
- declare module.exports: any;
-}
-
-declare module 'tcomb/lib/isObject' {
- declare module.exports: any;
-}
-
-declare module 'tcomb/lib/isString' {
- declare module.exports: any;
-}
-
-declare module 'tcomb/lib/isStruct' {
- declare module.exports: any;
-}
-
-declare module 'tcomb/lib/isSubsetOf' {
- declare module.exports: any;
-}
-
-declare module 'tcomb/lib/isType' {
- declare module.exports: any;
-}
-
-declare module 'tcomb/lib/isTypeName' {
- declare module.exports: any;
-}
-
-declare module 'tcomb/lib/isUnion' {
- declare module.exports: any;
-}
-
-declare module 'tcomb/lib/list' {
- declare module.exports: any;
-}
-
-declare module 'tcomb/lib/match' {
- declare module.exports: any;
-}
-
-declare module 'tcomb/lib/maybe' {
- declare module.exports: any;
-}
-
-declare module 'tcomb/lib/mixin' {
- declare module.exports: any;
-}
-
-declare module 'tcomb/lib/Nil' {
- declare module.exports: any;
-}
-
-declare module 'tcomb/lib/Number' {
- declare module.exports: any;
-}
-
-declare module 'tcomb/lib/Object' {
- declare module.exports: any;
-}
-
-declare module 'tcomb/lib/refinement' {
- declare module.exports: any;
-}
-
-declare module 'tcomb/lib/RegExp' {
- declare module.exports: any;
-}
-
-declare module 'tcomb/lib/String' {
- declare module.exports: any;
-}
-
-declare module 'tcomb/lib/stringify' {
- declare module.exports: any;
-}
-
-declare module 'tcomb/lib/struct' {
- declare module.exports: any;
-}
-
-declare module 'tcomb/lib/tuple' {
- declare module.exports: any;
-}
-
-declare module 'tcomb/lib/Type' {
- declare module.exports: any;
-}
-
-declare module 'tcomb/lib/union' {
- declare module.exports: any;
-}
-
-declare module 'tcomb/lib/update' {
- declare module.exports: any;
-}
-
-// Filename aliases
-declare module 'tcomb/index' {
- declare module.exports: $Exports<'tcomb'>;
-}
-declare module 'tcomb/index.js' {
- declare module.exports: $Exports<'tcomb'>;
-}
-declare module 'tcomb/lib/Any.js' {
- declare module.exports: $Exports<'tcomb/lib/Any'>;
-}
-declare module 'tcomb/lib/Array.js' {
- declare module.exports: $Exports<'tcomb/lib/Array'>;
-}
-declare module 'tcomb/lib/assert.js' {
- declare module.exports: $Exports<'tcomb/lib/assert'>;
-}
-declare module 'tcomb/lib/assign.js' {
- declare module.exports: $Exports<'tcomb/lib/assign'>;
-}
-declare module 'tcomb/lib/Boolean.js' {
- declare module.exports: $Exports<'tcomb/lib/Boolean'>;
-}
-declare module 'tcomb/lib/create.js' {
- declare module.exports: $Exports<'tcomb/lib/create'>;
-}
-declare module 'tcomb/lib/Date.js' {
- declare module.exports: $Exports<'tcomb/lib/Date'>;
-}
-declare module 'tcomb/lib/declare.js' {
- declare module.exports: $Exports<'tcomb/lib/declare'>;
-}
-declare module 'tcomb/lib/decompose.js' {
- declare module.exports: $Exports<'tcomb/lib/decompose'>;
-}
-declare module 'tcomb/lib/dict.js' {
- declare module.exports: $Exports<'tcomb/lib/dict'>;
-}
-declare module 'tcomb/lib/enums.js' {
- declare module.exports: $Exports<'tcomb/lib/enums'>;
-}
-declare module 'tcomb/lib/Error.js' {
- declare module.exports: $Exports<'tcomb/lib/Error'>;
-}
-declare module 'tcomb/lib/extend.js' {
- declare module.exports: $Exports<'tcomb/lib/extend'>;
-}
-declare module 'tcomb/lib/fail.js' {
- declare module.exports: $Exports<'tcomb/lib/fail'>;
-}
-declare module 'tcomb/lib/forbidNewOperator.js' {
- declare module.exports: $Exports<'tcomb/lib/forbidNewOperator'>;
-}
-declare module 'tcomb/lib/fromJSON.js' {
- declare module.exports: $Exports<'tcomb/lib/fromJSON'>;
-}
-declare module 'tcomb/lib/func.js' {
- declare module.exports: $Exports<'tcomb/lib/func'>;
-}
-declare module 'tcomb/lib/Function.js' {
- declare module.exports: $Exports<'tcomb/lib/Function'>;
-}
-declare module 'tcomb/lib/getDefaultInterfaceName.js' {
- declare module.exports: $Exports<'tcomb/lib/getDefaultInterfaceName'>;
-}
-declare module 'tcomb/lib/getFunctionName.js' {
- declare module.exports: $Exports<'tcomb/lib/getFunctionName'>;
-}
-declare module 'tcomb/lib/getTypeName.js' {
- declare module.exports: $Exports<'tcomb/lib/getTypeName'>;
-}
-declare module 'tcomb/lib/installTypeFormatter.js' {
- declare module.exports: $Exports<'tcomb/lib/installTypeFormatter'>;
-}
-declare module 'tcomb/lib/Integer.js' {
- declare module.exports: $Exports<'tcomb/lib/Integer'>;
-}
-declare module 'tcomb/lib/interface.js' {
- declare module.exports: $Exports<'tcomb/lib/interface'>;
-}
-declare module 'tcomb/lib/intersection.js' {
- declare module.exports: $Exports<'tcomb/lib/intersection'>;
-}
-declare module 'tcomb/lib/irreducible.js' {
- declare module.exports: $Exports<'tcomb/lib/irreducible'>;
-}
-declare module 'tcomb/lib/is.js' {
- declare module.exports: $Exports<'tcomb/lib/is'>;
-}
-declare module 'tcomb/lib/isArray.js' {
- declare module.exports: $Exports<'tcomb/lib/isArray'>;
-}
-declare module 'tcomb/lib/isBoolean.js' {
- declare module.exports: $Exports<'tcomb/lib/isBoolean'>;
-}
-declare module 'tcomb/lib/isFunction.js' {
- declare module.exports: $Exports<'tcomb/lib/isFunction'>;
-}
-declare module 'tcomb/lib/isIdentity.js' {
- declare module.exports: $Exports<'tcomb/lib/isIdentity'>;
-}
-declare module 'tcomb/lib/isInterface.js' {
- declare module.exports: $Exports<'tcomb/lib/isInterface'>;
-}
-declare module 'tcomb/lib/isMaybe.js' {
- declare module.exports: $Exports<'tcomb/lib/isMaybe'>;
-}
-declare module 'tcomb/lib/isNil.js' {
- declare module.exports: $Exports<'tcomb/lib/isNil'>;
-}
-declare module 'tcomb/lib/isNumber.js' {
- declare module.exports: $Exports<'tcomb/lib/isNumber'>;
-}
-declare module 'tcomb/lib/isObject.js' {
- declare module.exports: $Exports<'tcomb/lib/isObject'>;
-}
-declare module 'tcomb/lib/isString.js' {
- declare module.exports: $Exports<'tcomb/lib/isString'>;
-}
-declare module 'tcomb/lib/isStruct.js' {
- declare module.exports: $Exports<'tcomb/lib/isStruct'>;
-}
-declare module 'tcomb/lib/isSubsetOf.js' {
- declare module.exports: $Exports<'tcomb/lib/isSubsetOf'>;
-}
-declare module 'tcomb/lib/isType.js' {
- declare module.exports: $Exports<'tcomb/lib/isType'>;
-}
-declare module 'tcomb/lib/isTypeName.js' {
- declare module.exports: $Exports<'tcomb/lib/isTypeName'>;
-}
-declare module 'tcomb/lib/isUnion.js' {
- declare module.exports: $Exports<'tcomb/lib/isUnion'>;
-}
-declare module 'tcomb/lib/list.js' {
- declare module.exports: $Exports<'tcomb/lib/list'>;
-}
-declare module 'tcomb/lib/match.js' {
- declare module.exports: $Exports<'tcomb/lib/match'>;
-}
-declare module 'tcomb/lib/maybe.js' {
- declare module.exports: $Exports<'tcomb/lib/maybe'>;
-}
-declare module 'tcomb/lib/mixin.js' {
- declare module.exports: $Exports<'tcomb/lib/mixin'>;
-}
-declare module 'tcomb/lib/Nil.js' {
- declare module.exports: $Exports<'tcomb/lib/Nil'>;
-}
-declare module 'tcomb/lib/Number.js' {
- declare module.exports: $Exports<'tcomb/lib/Number'>;
-}
-declare module 'tcomb/lib/Object.js' {
- declare module.exports: $Exports<'tcomb/lib/Object'>;
-}
-declare module 'tcomb/lib/refinement.js' {
- declare module.exports: $Exports<'tcomb/lib/refinement'>;
-}
-declare module 'tcomb/lib/RegExp.js' {
- declare module.exports: $Exports<'tcomb/lib/RegExp'>;
-}
-declare module 'tcomb/lib/String.js' {
- declare module.exports: $Exports<'tcomb/lib/String'>;
-}
-declare module 'tcomb/lib/stringify.js' {
- declare module.exports: $Exports<'tcomb/lib/stringify'>;
-}
-declare module 'tcomb/lib/struct.js' {
- declare module.exports: $Exports<'tcomb/lib/struct'>;
-}
-declare module 'tcomb/lib/tuple.js' {
- declare module.exports: $Exports<'tcomb/lib/tuple'>;
-}
-declare module 'tcomb/lib/Type.js' {
- declare module.exports: $Exports<'tcomb/lib/Type'>;
-}
-declare module 'tcomb/lib/union.js' {
- declare module.exports: $Exports<'tcomb/lib/union'>;
-}
-declare module 'tcomb/lib/update.js' {
- declare module.exports: $Exports<'tcomb/lib/update'>;
-}
diff --git a/lib/types/messages/media.js b/lib/types/messages/media.js
--- a/lib/types/messages/media.js
+++ b/lib/types/messages/media.js
@@ -32,16 +32,18 @@
+media: $ReadOnlyArray<Media>,
};
+export type PhotoMessageServerDBContent = {
+ +type: 'photo',
+ +uploadID: string,
+};
+export type VideoMessageServerDBContent = {
+ +type: 'video',
+ +uploadID: string,
+ +thumbnailUploadID: string,
+};
export type MediaMessageServerDBContent =
- | {
- +type: 'photo',
- +uploadID: string,
- }
- | {
- +type: 'video',
- +uploadID: string,
- +thumbnailUploadID: string,
- };
+ | PhotoMessageServerDBContent
+ | VideoMessageServerDBContent;
function getUploadIDsFromMediaMessageServerDBContents(
mediaMessageContents: $ReadOnlyArray<MediaMessageServerDBContent>,
diff --git a/lib/utils/avatar-utils.js b/lib/utils/avatar-utils.js
--- a/lib/utils/avatar-utils.js
+++ b/lib/utils/avatar-utils.js
@@ -6,32 +6,41 @@
import { tRegex, tShape, tString } from './validation-utils.js';
import { validHexColorRegex } from '../shared/account-utils.js';
import { onlyOneEmojiRegex } from '../shared/emojis.js';
-
-const emojiAvatarDBContentValidator: TInterface = tShape({
+import type {
+ ENSAvatarDBContent,
+ EmojiAvatarDBContent,
+ ImageAvatarDBContent,
+ UpdateUserAvatarRemoveRequest,
+ UpdateUserAvatarRequest,
+} from '../types/avatar-types';
+
+const emojiAvatarDBContentValidator: TInterface<EmojiAvatarDBContent> = tShape({
type: tString('emoji'),
emoji: tRegex(onlyOneEmojiRegex),
color: tRegex(validHexColorRegex),
});
-const imageAvatarDBContentValidator: TInterface = tShape({
+const imageAvatarDBContentValidator: TInterface<ImageAvatarDBContent> = tShape({
type: tString('image'),
uploadID: t.String,
});
-const ensAvatarDBContentValidator: TInterface = tShape({
+const ensAvatarDBContentValidator: TInterface<ENSAvatarDBContent> = tShape({
type: tString('ens'),
});
-const updateUserAvatarRemoveRequestValidator: TInterface = tShape({
- type: tString('remove'),
-});
-
-const updateUserAvatarRequestValidator: TUnion<TInterface> = t.union([
- emojiAvatarDBContentValidator,
- imageAvatarDBContentValidator,
- ensAvatarDBContentValidator,
- updateUserAvatarRemoveRequestValidator,
-]);
+const updateUserAvatarRemoveRequestValidator: TInterface<UpdateUserAvatarRemoveRequest> =
+ tShape({
+ type: tString('remove'),
+ });
+
+const updateUserAvatarRequestValidator: TUnion<UpdateUserAvatarRequest> =
+ t.union([
+ emojiAvatarDBContentValidator,
+ imageAvatarDBContentValidator,
+ ensAvatarDBContentValidator,
+ updateUserAvatarRemoveRequestValidator,
+ ]);
export {
emojiAvatarDBContentValidator,
diff --git a/lib/utils/crypto-utils.js b/lib/utils/crypto-utils.js
--- a/lib/utils/crypto-utils.js
+++ b/lib/utils/crypto-utils.js
@@ -5,20 +5,26 @@
import { primaryIdentityPublicKeyRegex } from './siwe-utils.js';
import { tRegex, tShape } from './validation-utils.js';
+import type {
+ IdentityKeysBlob,
+ OLMIdentityKeys,
+ SignedIdentityKeysBlob,
+} from '../types/crypto-types';
const minimumOneTimeKeysRequired = 10;
-const signedIdentityKeysBlobValidator: TInterface = tShape({
- payload: t.String,
- signature: t.String,
-});
+const signedIdentityKeysBlobValidator: TInterface<SignedIdentityKeysBlob> =
+ tShape({
+ payload: t.String,
+ signature: t.String,
+ });
-const olmIdentityKeysValidator: TInterface = tShape({
+const olmIdentityKeysValidator: TInterface<OLMIdentityKeys> = tShape({
ed25519: tRegex(primaryIdentityPublicKeyRegex),
curve25519: tRegex(primaryIdentityPublicKeyRegex),
});
-const identityKeysBlobValidator: TInterface = tShape({
+const identityKeysBlobValidator: TInterface<IdentityKeysBlob> = tShape({
primaryIdentityPublicKeys: olmIdentityKeysValidator,
notificationIdentityPublicKeys: olmIdentityKeysValidator,
});
diff --git a/lib/utils/validation-utils.js b/lib/utils/validation-utils.js
--- a/lib/utils/validation-utils.js
+++ b/lib/utils/validation-utils.js
@@ -15,6 +15,12 @@
oldValidUsernameRegex,
validHexColorRegex,
} from '../shared/account-utils.js';
+import type { PlatformDetails } from '../types/device-types';
+import type {
+ MediaMessageServerDBContent,
+ PhotoMessageServerDBContent,
+ VideoMessageServerDBContent,
+} from '../types/messages/media';
function tBool(value: boolean): TIrreducible<boolean> {
return t.irreducible('literal bool', x => x === value);
@@ -28,7 +34,7 @@
return t.irreducible('literal number', x => x === value);
}
-function tShape(spec: TStructProps): TInterface {
+function tShape<T>(spec: TStructProps<T>): TInterface<T> {
return t.interface(spec, { strict: true });
}
@@ -58,7 +64,7 @@
'macos',
]);
const tDeviceType: TEnums = t.enums.of(['ios', 'android']);
-const tPlatformDetails: TInterface = tShape({
+const tPlatformDetails: TInterface<PlatformDetails> = tShape({
platform: tPlatform,
codeVersion: t.maybe(t.Number),
stateVersion: t.maybe(t.Number),
@@ -72,18 +78,18 @@
const tOldValidUsername: TRegex = tRegex(oldValidUsernameRegex);
const tID: TRefinement<string> = t.refinement(t.String, (id: string) => !!id);
-const tMediaMessagePhoto: TInterface = tShape({
+const tMediaMessagePhoto: TInterface<PhotoMessageServerDBContent> = tShape({
type: tString('photo'),
uploadID: t.String,
});
-const tMediaMessageVideo: TInterface = tShape({
+const tMediaMessageVideo: TInterface<VideoMessageServerDBContent> = tShape({
type: tString('video'),
uploadID: t.String,
thumbnailUploadID: t.String,
});
-const tMediaMessageMedia: TUnion<TInterface> = t.union([
+const tMediaMessageMedia: TUnion<MediaMessageServerDBContent> = t.union([
tMediaMessagePhoto,
tMediaMessageVideo,
]);

File Metadata

Mime Type
text/plain
Expires
Sun, Dec 7, 10:24 AM (17 h, 21 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5843496
Default Alt Text
D7467.1765103083.diff (28 KB)

Event Timeline