-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0eba0d8
commit 61447cd
Showing
2 changed files
with
92 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import { backendUri } from '$lib/backendUri'; | ||
import { Slangroom } from '@slangroom/core'; | ||
import getPbList from '$lib/slangroom/getPbList.zen?raw'; | ||
import { pocketbase } from '@slangroom/pocketbase'; | ||
|
||
export type VerificationFlow = { | ||
collectionId: string; | ||
collectionName: string; | ||
created: string; | ||
description: string; | ||
expand: Expand; | ||
id: string; | ||
name: string; | ||
organization: string; | ||
public: boolean; | ||
relying_party: string; | ||
template: string; | ||
updated: string; | ||
}; | ||
|
||
export type Expand = { | ||
organization: Organization; | ||
relying_party: RelyingParty; | ||
}; | ||
|
||
export type Organization = { | ||
avatar: string; | ||
collectionId: string; | ||
collectionName: string; | ||
created: string; | ||
description: string; | ||
id: string; | ||
name: string; | ||
updated: string; | ||
}; | ||
|
||
export type RelyingParty = { | ||
collectionId: string; | ||
collectionName: string; | ||
created: string; | ||
endpoint: string; | ||
id: string; | ||
name: string; | ||
organization: string; | ||
updated: string; | ||
}; | ||
export type PaginatedResult<T> = { | ||
page: number; | ||
perPage: number; | ||
totalItems: number; | ||
totalPages: number; | ||
items: T[]; | ||
}; | ||
|
||
export type Response<T> = { | ||
result: T; | ||
status: number; | ||
}; | ||
|
||
const slangroom = new Slangroom(pocketbase); | ||
|
||
export const getVerificationFlows = async (): Promise<VerificationFlow[]> => { | ||
try { | ||
const data = { | ||
pb_address: backendUri, | ||
list_parameters: { | ||
collection: 'verification_flows', | ||
expand: 'relying_party, organization', | ||
sort: '-updated', | ||
type: 'all' | ||
} | ||
}; | ||
const res = await slangroom.execute(getPbList, { data }); | ||
//@ts-expect-error output needs to be typed | ||
return res.result?.output?.records; | ||
} catch (e: unknown) { | ||
throw new Error(JSON.stringify(e)); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters