-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from curvenote/feat/session
User Sessions
- Loading branch information
Showing
25 changed files
with
262 additions
and
125 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
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 |
---|---|---|
@@ -1,17 +1,17 @@ | ||
import { ALL_BLOCKS, BlockId } from '@curvenote/blocks'; | ||
import { ALL_BLOCKS, BlockId, versionIdToString } from '@curvenote/blocks'; | ||
import { Block, Version, VersionQueryOpts } from '../models'; | ||
import { Session } from '../session'; | ||
import { ISession } from '../session/types'; | ||
|
||
export async function getLatestVersion<T extends ALL_BLOCKS>( | ||
session: Session, | ||
session: ISession, | ||
blockId: BlockId, | ||
query?: VersionQueryOpts, | ||
) { | ||
const block = await new Block(session, blockId).get(); | ||
const { latest_version } = block.data; | ||
if (!latest_version) throw new Error('Block has no versions'); | ||
const version = await new Version<T>(session, { ...block.id, version: latest_version }).get( | ||
query, | ||
); | ||
const versionId = { ...block.id, version: latest_version }; | ||
session.log.debug(`Fetching latest version of block: ${versionIdToString(versionId)}`); | ||
const version = await new Version<T>(session, versionId).get(query); | ||
return { block, version }; | ||
} |
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
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
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
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
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
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
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
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
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
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
Oops, something went wrong.