From ad28d182a37e7666695bf0503c25f07c8da29d0b Mon Sep 17 00:00:00 2001 From: Christiaan Landman Date: Wed, 24 Jun 2026 13:48:22 +0200 Subject: [PATCH 1/3] Added `AttachmentTableRecord` type, which describes the attachment table's type. --- .changeset/dry-bugs-invite.md | 5 +++ packages/common/src/attachments/Schema.ts | 46 +++++++++++++---------- 2 files changed, 31 insertions(+), 20 deletions(-) create mode 100644 .changeset/dry-bugs-invite.md diff --git a/.changeset/dry-bugs-invite.md b/.changeset/dry-bugs-invite.md new file mode 100644 index 000000000..3cbb3ed72 --- /dev/null +++ b/.changeset/dry-bugs-invite.md @@ -0,0 +1,5 @@ +--- +'@powersync/common': minor +--- + +[Attachments] Added `AttachmentTableRecord` type, which describes the attachment table's type. diff --git a/packages/common/src/attachments/Schema.ts b/packages/common/src/attachments/Schema.ts index 1714e1d75..178a7586c 100644 --- a/packages/common/src/attachments/Schema.ts +++ b/packages/common/src/attachments/Schema.ts @@ -1,5 +1,5 @@ import { column } from '../db/schema/Column.js'; -import { Table } from '../db/schema/Table.js'; +import { RowType, Table } from '../db/schema/Table.js'; import { TableV2Options } from '../db/schema/Table.js'; /** @@ -66,30 +66,36 @@ export enum AttachmentState { */ export interface AttachmentTableOptions extends Omit {} +const ATTACHMENT_TABLE_COLUMNS = { + filename: column.text, + local_uri: column.text, + timestamp: column.integer, + size: column.integer, + media_type: column.text, + state: column.integer, // Corresponds to AttachmentState + has_synced: column.integer, + meta_data: column.text +}; + /** * AttachmentTable defines the schema for the attachment queue table. * * @alpha */ -export class AttachmentTable extends Table { +export class AttachmentTable extends Table { constructor(options?: AttachmentTableOptions) { - super( - { - filename: column.text, - local_uri: column.text, - timestamp: column.integer, - size: column.integer, - media_type: column.text, - state: column.integer, // Corresponds to AttachmentState - has_synced: column.integer, - meta_data: column.text - }, - { - ...options, - viewName: options?.viewName ?? ATTACHMENT_TABLE, - localOnly: true, - insertOnly: false - } - ); + super(ATTACHMENT_TABLE_COLUMNS, { + ...options, + viewName: options?.viewName ?? ATTACHMENT_TABLE, + localOnly: true, + insertOnly: false + }); } } + +/** + * AttachmentTableRecord represents the row type of the attachment table. + * + * @alpha + */ +export type AttachmentTableRecord = RowType; From c066e9fcaa9c1fd60943fa4751dfcb5724fff732 Mon Sep 17 00:00:00 2001 From: Christiaan Landman Date: Wed, 24 Jun 2026 13:52:05 +0200 Subject: [PATCH 2/3] Update dry-bugs-invite.md --- .changeset/dry-bugs-invite.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/dry-bugs-invite.md b/.changeset/dry-bugs-invite.md index 3cbb3ed72..3e57b4df1 100644 --- a/.changeset/dry-bugs-invite.md +++ b/.changeset/dry-bugs-invite.md @@ -2,4 +2,4 @@ '@powersync/common': minor --- -[Attachments] Added `AttachmentTableRecord` type, which describes the attachment table's type. +[Attachments] Added `AttachmentTableRecord` type, which describes the attachment table's row type. From 6b68129ce8c9fe64bfcdd740ee266efe9b741546 Mon Sep 17 00:00:00 2001 From: Christiaan Landman Date: Wed, 24 Jun 2026 14:27:39 +0200 Subject: [PATCH 3/3] Extracted API fixes. --- packages/common/etc/common.api.md | 17 ++++++++++++++++- packages/common/src/attachments/Schema.ts | 5 ++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/packages/common/etc/common.api.md b/packages/common/etc/common.api.md index 9012adc3e..fa41eaed3 100644 --- a/packages/common/etc/common.api.md +++ b/packages/common/etc/common.api.md @@ -373,6 +373,18 @@ export interface ArrayQueryDefinition { // @alpha export const ATTACHMENT_TABLE = "attachments"; +// @alpha (undocumented) +export const ATTACHMENT_TABLE_COLUMNS: { + filename: BaseColumnType; + local_uri: BaseColumnType; + timestamp: BaseColumnType; + size: BaseColumnType; + media_type: BaseColumnType; + state: BaseColumnType; + has_synced: BaseColumnType; + meta_data: BaseColumnType; +}; + // @alpha export class AttachmentContext { constructor(db: AbstractPowerSyncDatabase, tableName: string | undefined, logger: ILogger, archivedCacheLimit: number); @@ -506,7 +518,7 @@ export enum AttachmentState { } // @alpha -export class AttachmentTable extends Table { +export class AttachmentTable extends Table { constructor(options?: AttachmentTableOptions); } @@ -514,6 +526,9 @@ export class AttachmentTable extends Table { export interface AttachmentTableOptions extends Omit { } +// @alpha +export type AttachmentTableRecord = RowType; + // @public (undocumented) export type BaseColumnType = { type: ColumnType; diff --git a/packages/common/src/attachments/Schema.ts b/packages/common/src/attachments/Schema.ts index 178a7586c..f7ac5bfe9 100644 --- a/packages/common/src/attachments/Schema.ts +++ b/packages/common/src/attachments/Schema.ts @@ -66,7 +66,10 @@ export enum AttachmentState { */ export interface AttachmentTableOptions extends Omit {} -const ATTACHMENT_TABLE_COLUMNS = { +/** + * @alpha + */ +export const ATTACHMENT_TABLE_COLUMNS = { filename: column.text, local_uri: column.text, timestamp: column.integer,