d25d482dc2
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
Publish CLI Package / publish-npm (push) Has been cancelled
Publish Python SDK / publish-pypi (push) Has been cancelled
Publish TypeScript SDK / publish-npm (push) Has been cancelled
54 lines
1.7 KiB
TypeScript
54 lines
1.7 KiB
TypeScript
export const FILE_PREVIEW_SESSION_SCHEMA_VERSION = 1 as const
|
|
|
|
export type FilePreviewTargetKind = 'new_file' | 'file_id'
|
|
export type FilePreviewStatus = 'pending' | 'streaming' | 'complete'
|
|
export type FilePreviewContentMode = 'delta' | 'snapshot'
|
|
|
|
export interface FilePreviewSession {
|
|
schemaVersion: typeof FILE_PREVIEW_SESSION_SCHEMA_VERSION
|
|
id: string
|
|
streamId: string
|
|
toolCallId: string
|
|
status: FilePreviewStatus
|
|
fileName: string
|
|
fileId?: string
|
|
targetKind?: FilePreviewTargetKind
|
|
operation?: string
|
|
edit?: Record<string, unknown>
|
|
baseContent?: string
|
|
previewText: string
|
|
previewVersion: number
|
|
updatedAt: string
|
|
completedAt?: string
|
|
}
|
|
|
|
export function isFilePreviewSession(value: unknown): value is FilePreviewSession {
|
|
if (!value || typeof value !== 'object') {
|
|
return false
|
|
}
|
|
|
|
const record = value as Record<string, unknown>
|
|
return (
|
|
record.schemaVersion === FILE_PREVIEW_SESSION_SCHEMA_VERSION &&
|
|
typeof record.id === 'string' &&
|
|
typeof record.streamId === 'string' &&
|
|
typeof record.toolCallId === 'string' &&
|
|
typeof record.status === 'string' &&
|
|
typeof record.fileName === 'string' &&
|
|
(record.baseContent === undefined || typeof record.baseContent === 'string') &&
|
|
typeof record.previewText === 'string' &&
|
|
typeof record.previewVersion === 'number' &&
|
|
typeof record.updatedAt === 'string'
|
|
)
|
|
}
|
|
|
|
export function sortFilePreviewSessions(sessions: FilePreviewSession[]): FilePreviewSession[] {
|
|
return [...sessions].sort((a, b) => {
|
|
const updatedAtCompare = a.updatedAt.localeCompare(b.updatedAt)
|
|
if (updatedAtCompare !== 0) {
|
|
return updatedAtCompare
|
|
}
|
|
return a.id.localeCompare(b.id)
|
|
})
|
|
}
|