Skip to content

Commit d18ab19

Browse files
committed
Types and tests.
1 parent 3124c9e commit d18ab19

5 files changed

Lines changed: 419 additions & 45 deletions

File tree

‎packages/powersync-db-collection/package.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@
5959
"p-defer": "^4.0.1"
6060
},
6161
"peerDependencies": {
62-
"@powersync/common": "^1.54.0"
62+
"@powersync/common": "^1.55.0"
6363
},
6464
"devDependencies": {
65-
"@powersync/common": "1.54.0",
65+
"@powersync/common": "1.55.0",
6666
"@powersync/node": "0.18.1",
6767
"@types/debug": "^4.1.12",
6868
"@vitest/coverage-istanbul": "^3.2.4",

‎packages/powersync-db-collection/src/attachments.ts‎

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -10,44 +10,22 @@ import { PowerSyncTransactor } from './PowerSyncTransactor'
1010
import type {
1111
AbstractPowerSyncDatabase,
1212
AttachmentData,
13-
AttachmentErrorHandler,
14-
ILogger,
15-
LocalStorageAdapter,
16-
RemoteStorageAdapter,
17-
WatchedAttachmentItem,
13+
AttachmentQueueOptions,
1814
} from '@powersync/common'
1915
import type { Collection } from '@tanstack/db'
2016

21-
type AttachmentQueueRow = (typeof _tmpSchema)['types']['attachments']
17+
export type AttachmentQueueRow = (typeof _tmpSchema)['types']['attachments']
2218

23-
/**
24-
* This extends the default AttachmentQueue constructor params
25-
* FIXME(powersync) we should export this type from the common SDK.
26-
*/
27-
type TanStackDBAttachmentQueueOptions = {
28-
db: AbstractPowerSyncDatabase
19+
export type TanStackDBAttachmentQueueOptions = AttachmentQueueOptions & {
2920
/**
3021
* For TanStack, we want access to the synced TanStackDB collection.
3122
* In order to have the same relational data be set in a single transaction.
3223
* This also allows for joining both TanStackDB collections.
3324
*/
34-
attachmentsCollection: Collection<AttachmentQueueRow>
35-
remoteStorage: RemoteStorageAdapter
36-
localStorage: LocalStorageAdapter
37-
watchAttachments: (
38-
onUpdate: (attachment: Array<WatchedAttachmentItem>) => Promise<void>,
39-
signal: AbortSignal,
40-
) => void
41-
tableName?: string
42-
logger?: ILogger
43-
syncIntervalMs?: number
44-
syncThrottleDuration?: number
45-
downloadAttachments?: boolean
46-
archivedCacheLimit?: number
47-
errorHandler?: AttachmentErrorHandler
25+
attachmentsCollection: Collection<AttachmentQueueRow, string>
4826
}
4927

50-
interface SaveFileTanStackOptions {
28+
export interface SaveFileTanStackOptions {
5129
data: AttachmentData
5230
fileExtension: string
5331
mediaType?: string
@@ -60,7 +38,7 @@ interface SaveFileTanStackOptions {
6038
updateHook?: (attachment: AttachmentQueueRow) => Promise<void>
6139
}
6240

63-
interface DeleteFileTanStackOptions {
41+
export interface DeleteFileTanStackOptions {
6442
id: string
6543
updateHook?: (attachment: AttachmentQueueRow) => Promise<void>
6644
}
@@ -74,7 +52,7 @@ const _tmpSchema = new Schema({
7452
*/
7553
export class TanStackDBAttachmentQueue extends AttachmentQueue {
7654
readonly powersync: AbstractPowerSyncDatabase
77-
readonly collection: Collection<AttachmentQueueRow>
55+
readonly collection: Collection<AttachmentQueueRow, string>
7856

7957
constructor(params: TanStackDBAttachmentQueueOptions) {
8058
super(params)

‎packages/powersync-db-collection/src/index.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
export * from './attachments'
12
export * from './definitions'
23
export * from './powersync'
34
export * from './PowerSyncTransactor'

0 commit comments

Comments
 (0)