move types to own file

This commit is contained in:
array-in-a-matrix 2023-12-09 15:43:12 -05:00
parent 281c6e987e
commit 71c16abd71
3 changed files with 34 additions and 28 deletions

View file

@ -1,33 +1,10 @@
{.emit:"import { MatrixClient } from 'matrix-bot-sdk';".}
type ICryptoStorageProvider = ref object
type storage = ref object
type cryptoStore = ref object
type Client* = ref object
homeserverUrl*: cstring
accessToken*: cstring
cryptoStore*: ICryptoStorageProvider
type Content* = ref object
body*, msgtype*: cstring
type Unsigned* = ref object
transaction_id*: cstring
type Event* = ref object
content*: Content
unsigned*: Unsigned
event_id*, sender*, `type`*, room_id*: cstring
origin_server_ts*: int
type Filter* = ref object
import matrixTypes
proc newMatrixClient*(homeserver, token: cstring): Client {.importjs: "new MatrixClient(#, #)".}
proc newMatrixClient*(homeserver, token: cstring, storage: storage): Client {.importjs: "new MatrixClient(#, #, #)".}
proc newMatrixClient*(homeserver, token: cstring, storage: storage, cryptoStore: cryptoStore): Client {.importjs: "new MatrixClient(#, #, #, #)".}
proc newMatrixClient*(homeserver, token: cstring, storage: Storage): Client {.importjs: "new MatrixClient(#, #, #)".}
proc newMatrixClient*(homeserver, token: cstring, storage: Storage, cryptoStore: CryptoStore): Client {.importjs: "new MatrixClient(#, #, #, #)".}
proc start*(client: Client, filter: Filter = nil) {.importjs: "#.start(#)".} #? returns a promise

29
src/matrixTypes.nim Normal file
View file

@ -0,0 +1,29 @@
type ICryptoStorageProvider* = ref object
type Storage* = ref object
type CryptoStore* = ref object
type Auth* = ref object
homeserverUrl: cstring
type Client* = ref object
homeserverUrl*: cstring
accessToken*: cstring
cryptoStore*: ICryptoStorageProvider
type Content* = ref object
body*, msgtype*: cstring
type Unsigned* = ref object
transaction_id*: cstring
type Event* = ref object
content*: Content
unsigned*: Unsigned
event_id*, sender*, `type`*, room_id*: cstring
origin_server_ts*: int
type Filter* = ref object
type Appservice* = ref object

View file

@ -1,7 +1,7 @@
{.emit:"import { SimpleFsStorageProvider } from 'matrix-bot-sdk';".}
type storage = ref object
import matrixTypes
proc newSimpleFsStorageProvider*(filename: cstring): storage {.importjs: "new SimpleFsStorageProvider(#)".}
proc newSimpleFsStorageProvider*(filename: cstring): Storage {.importjs: "new SimpleFsStorageProvider(#)".}
proc newSimpleFsStorageProvider*(filename: cstring, trackTransactionsInMemory: bool): storage {.importjs: "new SimpleFsStorageProvider(#, #)".}
proc newSimpleFsStorageProvider*(filename: cstring, trackTransactionsInMemory: bool, maxInMemoryTransactions: int): storage {.importjs: "new SimpleFsStorageProvider(#, #, #)".}