Page MenuHomePhabricator

D13315.id44244.diff
No OneTemporary

D13315.id44244.diff

diff --git a/keyserver/src/updaters/entry-updaters.js b/keyserver/src/updaters/entry-updaters.js
--- a/keyserver/src/updaters/entry-updaters.js
+++ b/keyserver/src/updaters/entry-updaters.js
@@ -157,7 +157,7 @@
`),
);
}
- const updatedEntryInfo = {
+ const updatedEntryInfo: RawEntryInfo = {
...entryInfo,
text: request.text,
};
diff --git a/lib/types/entry-types.js b/lib/types/entry-types.js
--- a/lib/types/entry-types.js
+++ b/lib/types/entry-types.js
@@ -1,6 +1,6 @@
// @flow
-import t, { type TInterface } from 'tcomb';
+import t, { type TInterface, type TUnion } from 'tcomb';
import { type Platform, isWebPlatform } from './device-types.js';
import {
@@ -19,37 +19,65 @@
fifteenDaysLater,
thisMonthDates,
} from '../utils/date-utils.js';
-import { tUserID, tID, tShape } from '../utils/validation-utils.js';
+import { tUserID, tID, tShape, tBool } from '../utils/validation-utils.js';
-export type RawEntryInfo = {
- id?: string, // null if local copy without ID yet
- localID?: string, // for optimistic creations
- threadID: string,
- text: string,
- year: number,
- month: number, // 1-indexed
- day: number, // 1-indexed
- creationTime: number, // millisecond timestamp
- creatorID: string,
- deleted: boolean,
+export type RawEntryInfoBase = {
+ +id?: string, // null if local copy without ID yet
+ +localID?: string, // for optimistic creations
+ +threadID: string,
+ +text: string,
+ +year: number,
+ +month: number, // 1-indexed
+ +day: number, // 1-indexed
+ +creationTime: number, // millisecond timestamp
+ +creatorID: string,
+ +deleted: boolean,
};
-export type RawEntryInfos = {
- +[id: string]: RawEntryInfo,
+const rawEntryInfoBaseValidatorShape = {
+ localID: t.maybe(t.String),
+ threadID: tID,
+ text: t.String,
+ year: t.Number,
+ month: t.Number,
+ day: t.Number,
+ creationTime: t.Number,
+ creatorID: tUserID,
+ deleted: t.Boolean,
};
-export const rawEntryInfoValidator: TInterface<RawEntryInfo> =
- tShape<RawEntryInfo>({
+
+export type ThinRawEntryInfo = $ReadOnly<{
+ ...RawEntryInfoBase,
+ id?: string,
+}>;
+const thinRawEntryInfoValidator: TInterface<ThinRawEntryInfo> =
+ tShape<ThinRawEntryInfo>({
+ ...rawEntryInfoBaseValidatorShape,
id: t.maybe(tID),
- localID: t.maybe(t.String),
- threadID: tID,
- text: t.String,
- year: t.Number,
- month: t.Number,
- day: t.Number,
- creationTime: t.Number,
- creatorID: tUserID,
- deleted: t.Boolean,
});
+export type ThickRawEntryInfo = $ReadOnly<{
+ ...RawEntryInfoBase,
+ +id: string,
+ +thick: true,
+ +lastUpdatedTime: number,
+}>;
+const thickRawEntryInfoValidator: TInterface<ThickRawEntryInfo> =
+ tShape<ThickRawEntryInfo>({
+ ...rawEntryInfoBaseValidatorShape,
+ id: t.String,
+ thick: tBool(true),
+ lastUpdatedTime: t.Number,
+ });
+
+export type RawEntryInfo = ThinRawEntryInfo | ThickRawEntryInfo;
+export const rawEntryInfoValidator: TUnion<RawEntryInfo> = t.union([
+ thinRawEntryInfoValidator,
+ thickRawEntryInfoValidator,
+]);
+export type RawEntryInfos = {
+ +[id: string]: RawEntryInfo,
+};
+
export type EntryInfo = {
id?: string, // null if local copy without ID yet
localID?: string, // for optimistic creations

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 23, 2:57 AM (18 h, 1 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2564608
Default Alt Text
D13315.id44244.diff (3 KB)

Event Timeline