Skip to content

Commit df621ec

Browse files
committed
alias types to zod-model types to avoid massive refactor
1 parent ef627e1 commit df621ec

File tree

11 files changed

+46
-254
lines changed

11 files changed

+46
-254
lines changed

web/src/migrating/model/allProjectsDataExport.ts

Lines changed: 0 additions & 17 deletions
This file was deleted.

web/src/migrating/model/projectExportData.ts

Lines changed: 0 additions & 50 deletions
This file was deleted.

web/src/types/connection.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,3 @@
1-
import { z } from 'zod'
2-
import { ActionHashB64 } from './shared'
1+
import { Connection as _Connection } from 'zod-models'
32

4-
export const ConnectionSchema = z.object({
5-
parentActionHash: z.string(),
6-
childActionHash: z.string(),
7-
randomizer: z.number(),
8-
isImported: z.boolean(),
9-
})
10-
export interface Connection {
11-
parentActionHash: ActionHashB64
12-
childActionHash: ActionHashB64
13-
randomizer: number //i64,
14-
isImported: boolean
15-
}
3+
export type Connection = _Connection

web/src/types/entryPoint.ts

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,3 @@
1-
import { z } from 'zod'
2-
import { AgentPubKeyB64, ActionHashB64 } from './shared'
1+
import { EntryPoint as _EntryPoint } from 'zod-models'
32

4-
export const EntryPointSchema = z.object({
5-
color: z.string(),
6-
creatorAgentPubKey: z.string(),
7-
createdAt: z.number(),
8-
outcomeActionHash: z.string(),
9-
isImported: z.boolean(),
10-
})
11-
export interface EntryPoint {
12-
color: string
13-
creatorAgentPubKey: AgentPubKeyB64
14-
createdAt: number //f64,
15-
outcomeActionHash: ActionHashB64
16-
isImported: boolean
17-
}
3+
export type EntryPoint = _EntryPoint

web/src/types/outcome.ts

Lines changed: 20 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,31 @@
1-
import { z } from 'zod'
21
import { OutcomeComment } from './outcomeComment'
32
import { OutcomeVote } from './outcomeVote'
43
import { Profile } from './profile'
5-
import { AgentPubKeyB64, Option, WithActionHash } from './shared'
4+
import { WithActionHash } from './shared'
5+
import {
6+
SmallTask as _SmallTask,
7+
SmallScope as _SmallScope,
8+
TimeFrame as _TimeFrame,
9+
SmallsEstimate as _SmallsEstimate,
10+
UncertainScope as _UncertainScope,
11+
Scope as _Scope,
12+
Outcome as _Outcome,
13+
} from 'zod-models'
614

715
export type AchievementStatus = 'Achieved' | 'NotAchieved'
816

9-
export const SmallTaskSchema = z.object({
10-
complete: z.boolean(),
11-
task: z.string(),
12-
})
13-
export type SmallTask = {
14-
complete: boolean
15-
task: string
16-
}
17-
18-
export const SmallScopeSchema = z.object({
19-
achievementStatus: z.enum(['Achieved', 'NotAchieved']),
20-
targetDate: z.number().optional(),
21-
taskList: z.array(SmallTaskSchema),
22-
})
23-
export interface SmallScope {
24-
achievementStatus: AchievementStatus
25-
targetDate: Option<number>
26-
taskList: Array<SmallTask>
27-
}
28-
29-
export const TimeFrameSchema = z.object({
30-
fromDate: z.number(),
31-
toDate: z.number(),
32-
})
33-
export interface TimeFrame {
34-
fromDate: number //f64,
35-
toDate: number //f64,
36-
}
37-
export const SmallsEstimateSchema = z.number()
38-
export type SmallsEstimate = number
39-
40-
export const UncertainScopeSchema = z.object({
41-
smallsEstimate: SmallsEstimateSchema.optional(),
42-
timeFrame: TimeFrameSchema,
43-
inBreakdown: z.boolean(),
44-
})
45-
export interface UncertainScope {
46-
smallsEstimate: Option<SmallsEstimate>
47-
timeFrame: Option<TimeFrame>
48-
inBreakdown: boolean
49-
}
17+
export type SmallTask = _SmallTask
18+
export type SmallScope = _SmallScope
19+
export type SmallsEstimate = _SmallsEstimate
20+
export type ScopeSmallVariant = SmallScope
5021

51-
export type ScopeSmallVariant = { Small: SmallScope }
52-
export type ScopeUncertainVariant = { Uncertain: UncertainScope }
22+
export type TimeFrame = _TimeFrame
23+
export type UncertainScope = _UncertainScope
24+
export type ScopeUncertainVariant = UncertainScope
5325

54-
export const ScopeSchema = z.union([SmallScopeSchema, UncertainScopeSchema])
55-
export type Scope = ScopeSmallVariant | ScopeUncertainVariant
26+
export type Scope = _Scope
5627

28+
// TODO: convert to zod schema
5729
export type ComputedAchievementStatus = {
5830
uncertains: number
5931
smallsAchieved: number
@@ -63,30 +35,7 @@ export type ComputedAchievementStatus = {
6335
simple: ComputedSimpleAchievementStatus
6436
}
6537

66-
export const OutcomeSchema = z.object({
67-
content: z.string(),
68-
creatorAgentPubKey: z.string(),
69-
editorAgentPubKey: z.string().optional(),
70-
timestampCreated: z.number().gt(0),
71-
timestampUpdated: z.number().gt(0).optional(),
72-
scope: ScopeSchema,
73-
tags: z.array(z.string()).optional(),
74-
description: z.string(),
75-
isImported: z.boolean(),
76-
githubLink: z.string().url(),
77-
})
78-
export interface Outcome {
79-
content: string
80-
creatorAgentPubKey: AgentPubKeyB64
81-
editorAgentPubKey: Option<AgentPubKeyB64>
82-
timestampCreated: number //f64,
83-
timestampUpdated: Option<number> //f64
84-
scope: Scope
85-
tags: Option<Array<string>>
86-
description: string
87-
isImported: boolean
88-
githubLink: string
89-
}
38+
export type Outcome = _Outcome
9039
/*
9140
Uncertain
9241
{

web/src/types/outcomeComment.ts

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,3 @@
1-
import { z } from 'zod'
2-
import { AgentPubKeyB64, ActionHashB64 } from './shared'
1+
import { OutcomeComment as _OutcomeComment } from 'zod-models'
32

4-
export const OutcomeCommentSchema = z.object({
5-
outcomeActionHash: z.string(),
6-
content: z.string(),
7-
creatorAgentPubKey: z.string(),
8-
unixTimestamp: z.number(),
9-
isImported: z.boolean(),
10-
})
11-
export interface OutcomeComment {
12-
outcomeActionHash: ActionHashB64
13-
content: string
14-
creatorAgentPubKey: AgentPubKeyB64
15-
unixTimestamp: number //f64,
16-
isImported: boolean
17-
}
3+
export type OutcomeComment = _OutcomeComment

web/src/types/outcomeMember.ts

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,3 @@
1-
import { z } from 'zod'
2-
import { ActionHashB64, AgentPubKeyB64 } from './shared'
1+
import { OutcomeMember as _OutcomeMember } from 'zod-models'
32

4-
export const OutcomeMemberSchema = z.object({
5-
outcomeActionHash: z.string(),
6-
memberAgentPubKey: z.string(),
7-
creatorAgentPubKey: z.string(),
8-
unixTimestamp: z.number(),
9-
isImported: z.boolean(),
10-
})
11-
export interface OutcomeMember {
12-
outcomeActionHash: ActionHashB64
13-
// the "assignee"
14-
memberAgentPubKey: AgentPubKeyB64
15-
// the person who authored this entry
16-
creatorAgentPubKey: AgentPubKeyB64
17-
unixTimestamp: number //f64,
18-
isImported: boolean
19-
}
3+
export type OutcomeMember = _OutcomeMember

web/src/types/outcomeVote.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
import { ActionHashB64, AgentPubKeyB64 } from "./shared"
1+
import { ActionHashB64, AgentPubKeyB64 } from './shared'
22

3+
// TODO: convert to zod schema
34
export interface OutcomeVote {
4-
outcomeActionHash: ActionHashB64,
5-
urgency: number, //f64,
6-
importance: number, //f64,
7-
impact: number, //f64,
8-
effort: number, //f64,
9-
creatorAgentPubKey: AgentPubKeyB64,
10-
unixTimestamp: number, //f64,
11-
isImported: boolean,
5+
outcomeActionHash: ActionHashB64
6+
urgency: number //f64,
7+
importance: number //f64,
8+
impact: number //f64,
9+
effort: number //f64,
10+
creatorAgentPubKey: AgentPubKeyB64
11+
unixTimestamp: number //f64,
12+
isImported: boolean
1213
}

web/src/types/profile.ts

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,7 @@
1-
import { z } from 'zod'
2-
import { AgentPubKeyB64, ActionHashB64 } from './shared'
1+
import { Profile as _Profile } from 'zod-models'
2+
import { ActionHashB64 } from './shared'
33

4-
type Status = 'Online' | 'Offline' | 'Away'
5-
6-
export const ProfileSchema = z.object({
7-
firstName: z.string(),
8-
lastName: z.string(),
9-
handle: z.string(),
10-
status: z.enum(['Online', 'Offline', 'Away']),
11-
avatarUrl: z.string(),
12-
agentPubKey: z.string(),
13-
isImported: z.boolean(),
14-
})
15-
export interface Profile {
16-
firstName: string
17-
lastName: string
18-
handle: string
19-
status: Status
20-
avatarUrl: string
21-
agentPubKey: AgentPubKeyB64
22-
isImported: boolean
23-
}
4+
export type Profile = _Profile
245

256
export type AssigneeWithActionHash = {
267
profile: Profile

web/src/types/projectMeta.ts

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
1-
import { z } from 'zod'
21
import { EntryPoint } from './entryPoint'
32
import { Outcome } from './outcome'
43
import { Profile } from './profile'
5-
import {
6-
AgentPubKeyB64,
7-
ActionHashB64,
8-
Option,
9-
CellIdString,
10-
WithActionHash,
11-
} from './shared'
12-
import { ProjectMetaV1, ProjectMetaV1Schema } from 'zod-models'
4+
import { AgentPubKeyB64, CellIdString, WithActionHash } from './shared'
5+
import { ProjectMetaV1 } from 'zod-models'
136

147
export type ProjectAggregated = {
15-
projectMeta: WithActionHash<ProjectMeta>
8+
projectMeta: WithActionHash<ProjectMetaV1>
169
cellId: CellIdString
1710
presentMembers: AgentPubKeyB64[]
1811
members: Profile[]
@@ -21,5 +14,3 @@ export type ProjectAggregated = {
2114
outcome: WithActionHash<Outcome>
2215
}[]
2316
}
24-
25-
export type ProjectMeta = ProjectMetaV1

0 commit comments

Comments
 (0)