Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 91 additions & 0 deletions packages/types/tailor.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,99 @@ declare namespace Tailordb {
| "CREATE";
}

/**
* File stream iterator for TailorDB file downloads
*/
interface TailordbFileStreamIterator {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AsyncIterableIterator という言語標準の型があるみたいです。value はanyになっていますがUint8Arrayに制約できるであっていますでしょうか?

interface TailordbFileStreamIterator extends AsyncIterableIterator<Uint8Array> {
  close(): Promise<void>;
}

/**
* Get next chunk from the stream
*/
next(): Promise<{ done: boolean; value?: any }>;

/**
* Close the stream session
*/
close(): Promise<void>;

/**
* AsyncIterator symbol for for-await-of loops
*/
[Symbol.asyncIterator](): TailordbFileStreamIterator;
}

declare const tailordb: {
Client: typeof Tailordb.Client;
file: {
/**
* Upload file to TailorDB
*/
upload(
namespace: string,
typeName: string,
fieldName: string,
recordId: string,
data: string | ArrayBuffer | Uint8Array | number[],
options?: {
contentType?: string;
}
): Promise<{
metadata: {
fileSize: number;
sha256sum: string;
}
}>;

/**
* Download file from TailorDB
*/
download(
namespace: string,
typeName: string,
fieldName: string,
recordId: string
): Promise<{
data: Uint8Array;
metadata: {
contentType: string;
fileSize: number;
}

@takumiyoshikawa takumiyoshikawa Sep 26, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[q]
fileのrecordはあるが、file uploadがまだされていない状態の時にundefiendは返りますか?あるいはdefaultの空文字やfilesize 0が帰りますか?あるいはerror?

}>;

/**
* Open download stream for large files
*/
openDownloadStream(
namespace: string,
typeName: string,
fieldName: string,
recordId: string
): Promise<TailordbFileStreamIterator>;

/**
* Delete file from TailorDB
*/
delete(
namespace: string,
typeName: string,
fieldName: string,
recordId: string
): Promise<boolean>;

/**
* Get file metadata from TailorDB
*/
getMetadata(
namespace: string,
typeName: string,
fieldName: string,
recordId: string
): Promise<{
contentType: string;
fileSize: number;
sha256sum: string;
lastUploadedAt: string;
}>;
};

@takumiyoshikawa takumiyoshikawa Sep 26, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

こちらもuploadしていない状況でのundefinedなどが返るかどうかが気になります

};

declare namespace tailor.secretmanager {
Expand Down