Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

utilize more types in LFNext #1664

Merged
merged 61 commits into from
Jan 10, 2023
Merged
Changes from 1 commit
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
e437c5d
corrected file extension
Dec 8, 2022
851687f
typed sf call
Dec 9, 2022
b250349
missed a possibility
Dec 9, 2022
be97967
typed the activities api
Dec 9, 2022
e6aed83
cleaned up some param syntax
Dec 9, 2022
b7b40ec
Merge branch 'develop' into chore/types
Dec 13, 2022
1a48cba
Merge branch 'develop' into chore/types
Dec 21, 2022
b06a2f9
changed extensions for TS
Dec 21, 2022
a65686c
upgraded more deps
Dec 21, 2022
eb03cef
resolved ts warning
Dec 21, 2022
0610f49
preferring type over interface
Dec 21, 2022
658dc7a
type the event
Dec 21, 2022
db04118
class attr not needed at this point
Dec 21, 2022
872c9db
class attr not needed
Dec 21, 2022
c0f60f1
cleaned up sf wrapper
Dec 21, 2022
8af30c1
tried different typing approach
Dec 21, 2022
14a5e22
typed dashboard page
Dec 21, 2022
1025ae0
renamed result
Dec 21, 2022
7d85c9a
typed some of the dashboard code
Dec 22, 2022
a029d7b
fixed some "undefined" classes showing up in final HTML
Dec 22, 2022
ac5cc79
gave up on correcting this ts error
Dec 22, 2022
5e96bb4
typed the Input comp
Dec 22, 2022
411f350
didn't want playground to autoscroll to the focused input
Dec 22, 2022
ab8a30e
typed sf calls
Dec 22, 2022
22b01b7
typed Progress comp
Dec 22, 2022
67f89a5
typed client-side fetch normalizer
Dec 23, 2022
1d35ae7
removed tsc warning
Dec 23, 2022
0c5a75f
addressed tsc warning
Dec 23, 2022
0d2151a
type the Sf response
Dec 23, 2022
26a3e2d
resolved some tsc warnings
Dec 23, 2022
45a6f87
addressed some type hints
Dec 23, 2022
4e208e2
typed user call
Dec 23, 2022
9f4a8fc
typed project details call a little more
Dec 23, 2022
7bfcb3b
addressed a couple more type warnings
Dec 23, 2022
1a8f9fe
consistent convention
Dec 24, 2022
9741324
typed some transforms
Dec 24, 2022
6b0b3d8
consistent convention
Dec 24, 2022
815c0c6
Merge branch 'develop' into chore/types
Dec 24, 2022
b821149
Merge branch 'develop' into chore/types
Jan 3, 2023
d6448da
Merge branch 'develop' into chore/types
Jan 4, 2023
02061b4
incorporated PR feedback
Jan 4, 2023
c5323cc
incorporated PR feedback
Jan 4, 2023
31d2e35
incorporated PR feedback
Jan 4, 2023
684a7f1
incorporated PR feedback
Jan 4, 2023
4ee2094
incorporated PR feedback
Jan 4, 2023
9f1fce8
Merge branch 'develop' into chore/types
Jan 5, 2023
fccc305
simplified audio/picture detection algorithm
Jan 5, 2023
cc966de
incorporated PR feedback
Jan 5, 2023
20f57f6
eliminated use of types.d.ts files
Jan 6, 2023
c2d0749
Merge branch 'develop' into chore/types
Jan 6, 2023
5123da7
Merge branch 'develop' into chore/types
Jan 6, 2023
00f3bf6
updated deps
Jan 6, 2023
d7ecf3b
incorporated PR feedback
Jan 9, 2023
d6dac14
incorporated PR feedback
Jan 9, 2023
31338f2
eliminated remaining `svelte check` warnings
Jan 9, 2023
3046119
accepted PR suggestion
Jan 9, 2023
3e02ce2
incorporated PR feedback
Jan 9, 2023
85cef15
accepted PR suggestion
Jan 9, 2023
c3b7322
incorporated PR feedback
Jan 9, 2023
e45a2d2
simplified error handling
Jan 9, 2023
776d44c
Merge branch 'develop' into chore/types
Jan 9, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
eliminated use of types.d.ts files
billy clark committed Jan 6, 2023
commit 20f57f65ea1c8837a0011a52dad5cac9363f7c5f
2 changes: 1 addition & 1 deletion next-app/src/lib/Stats.svelte
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@

type Stat = {
title: string,
value: number,
value: number | undefined,
longrunningprocess marked this conversation as resolved.
Show resolved Hide resolved
icon?: any,
hahn-kev marked this conversation as resolved.
Show resolved Hide resolved
url?: string | URL,
}
12 changes: 11 additions & 1 deletion next-app/src/lib/fetch.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
import { throw_error } from '$lib/error'
import { start, stop } from '$lib/progress'
import type { AdaptedFetchArgs, FetchArgs } from './types'
import type { HttpMethod } from '@sveltejs/kit/types/private'

type AdaptedFetchArgs = {
url: string,
method: HttpMethod,
body?: object,
}
type FetchArgs = {
myieye marked this conversation as resolved.
Show resolved Hide resolved
url: string,
body?: object,
}

export async function CREATE({url, body}: FetchArgs) { return await adapted_fetch({method: 'POST' , url, body}) }
export async function GET ({url }: FetchArgs) { return await adapted_fetch({method: 'GET' , url }) }
22 changes: 21 additions & 1 deletion next-app/src/lib/server/sf.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
import { error } from '@sveltejs/kit'
import type { Rpc, FetchArgs, SfResponse } from './types'
import type { HttpMethod } from '@sveltejs/kit/types/private'

export type Rpc = {
myieye marked this conversation as resolved.
Show resolved Hide resolved
name: string,
args?: string[] | object[],
myieye marked this conversation as resolved.
Show resolved Hide resolved
cookie?: string,
}

type FetchArgs = {
url: string,
method: HttpMethod,
body: object,
cookie?: string,
}

type SfResponse = {
error?: {
message: string
},
result?: any,
}

export async function sf<T>({name, args = [], cookie = ''}: Rpc): Promise<T> {
const body = {
31 changes: 0 additions & 31 deletions next-app/src/lib/server/types.d.ts

This file was deleted.

11 changes: 10 additions & 1 deletion next-app/src/lib/server/user.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
import { error } from '@sveltejs/kit'
import { sf } from '$lib/server/sf'
import type { LegacySession, User } from './types'

type LegacySession = {
userId: string,
userProjectRole: string,
}

type User = {
id: string,
role: string,
}

export async function fetch_current_user(cookie: string): Promise<User> {
const { userId, userProjectRole }: LegacySession = await sf({
11 changes: 0 additions & 11 deletions next-app/src/lib/types.d.ts

This file was deleted.

9 changes: 7 additions & 2 deletions next-app/src/routes/projects/[project_code]/+page.server.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import { fetch_activities } from './activities/+server'
import { fetch_project_details } from './meta/+server'
import { fetch_activities, type Activity } from './activities/+server'
import { fetch_project_details, type ProjectDetails } from './meta/+server'
import { can_view_activity } from '$lib/auth'
import { fetch_current_user } from '$lib/server/user'
import type { RequestEvent } from './$types'

export type DashboardData = {
project: ProjectDetails,
activities?: undefined | Activity[],
longrunningprocess marked this conversation as resolved.
Show resolved Hide resolved
}

export async function load({ params: { project_code }, request: { headers }}: RequestEvent): Promise<DashboardData> {
const args = {
project_code,
2 changes: 1 addition & 1 deletion next-app/src/routes/projects/[project_code]/+page.svelte
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@
import { Button } from '$lib/forms'
import PageHeader from '$lib/PageHeader.svelte'
import Stats from '$lib/Stats.svelte'
import type { DashboardData } from './types'
import type { DashboardData } from './+page.server'

export let data: DashboardData

13 changes: 10 additions & 3 deletions next-app/src/routes/projects/[project_code]/Activity.svelte
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
<script lang=ts>
import type { AugmentedActivity } from './types'
import type { Activity, Field } from './activities/+server'

export let activities: Activity[]

interface AugmentedActivity extends Activity {
date_locale: string,
date_iso: string,
time: number,
field_names: string,
}

$: sorted_activities = transform(activities).sort(byDateThenUser)

// mappings in src/Api/Model/Shared/ActivityModel.php
@@ -31,7 +38,7 @@
date_locale: date.toLocaleDateString(),
date_iso: date.toISOString().split('T')[0],
time: date.getTime(),
fields: to_names(activity.fields),
field_names: to_names(activity.fields),
}
})
}
@@ -69,7 +76,7 @@
<td>{ activity.date_locale }</td>
<td>{ action_display[activity.action] || activity.action }</td>
<td>{ activity.entry || '—' }</td>
<td>{ activity.fields || '—' }</td>
<td>{ activity.field_names || '—' }</td>
</tr>
{:else}
<tr><td>No activity</td></tr>
37 changes: 35 additions & 2 deletions next-app/src/routes/projects/[project_code]/activities/+server.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,41 @@
import { json } from '@sveltejs/kit'
import { sf } from '$lib/server/sf'
import type { Rpc } from '$lib/server/types'
import { sf, type Rpc } from '$lib/server/sf'
import type { RequestEvent } from './$types'

type ActivitiesInput = {
cookie: string,
start_date?: Date,
end_date?: Date,
}

type LegacyResult = {
activity: LegacyActivity[],
}

export type Field = {
name: string,
}

type LegacyActivity = {
id: string,
action: string,
date: string,
content: {
user: string,
entry?: string,
changes?: Field[],
},
}

export type Activity = {
id: string,
action: string,
date: string,
user: string,
entry: string,
fields: Field[],
}

export async function GET({ params: { project_code }, request: { headers } }: RequestEvent) {
const cookie = headers.get('cookie') || ''

33 changes: 0 additions & 33 deletions next-app/src/routes/projects/[project_code]/activities/types.d.ts

This file was deleted.

27 changes: 26 additions & 1 deletion next-app/src/routes/projects/[project_code]/meta/+server.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,32 @@
import { can_view_comments } from '$lib/auth'
import { fetch_current_user } from '$lib/server/user'
import { sf } from '$lib/server/sf'
import type { LegacyProjectDetails, LegacyStats, ProjectDetails } from './types'

type LegacyProjectDetails = {
id: string,
projectName: string,
users: object[],
}

type LegacyStats = {
entries: object[],
comments: Comment[],
}

type Comment = {
status: string,
}

export type ProjectDetails = {
id: string,
code: string,
name: string,
num_users: number,
num_entries: number,
num_entries_with_audio: number,
num_entries_with_pictures: number,
num_unresolved_comments?: number,
}

export async function fetch_project_details({ project_code, cookie }) {
const { id, projectName: name, users }: LegacyProjectDetails = await sf({ name: 'set_project', args: [ project_code ], cookie })
29 changes: 0 additions & 29 deletions next-app/src/routes/projects/[project_code]/meta/types.d.ts

This file was deleted.

13 changes: 0 additions & 13 deletions next-app/src/routes/projects/[project_code]/types.d.ts

This file was deleted.