UNPKG

@aristech-org/nlp-client

Version:

A Node.js client library for the Aristech NLP Service

1,672 lines (1,540 loc) 90.3 kB
// Code generated by protoc-gen-ts_proto. DO NOT EDIT. // versions: // protoc-gen-ts_proto v2.11.8 // protoc v6.33.1 // source: documents.proto /* eslint-disable */ import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire"; import { History } from "./projects.js"; export const protobufPackage = "aristech.nlp"; export enum ContentType { IMAGE_PNG = 0, APPLICATION_MD = 1, APPLICATION_TXT = 2, APPLICATION_PDF = 3, IMAGE_JPEG = 4, IMAGE_WEBP = 5, APPLICATION_XLSX = 6, UNRECOGNIZED = -1, } export function contentTypeFromJSON(object: any): ContentType { switch (object) { case 0: case "IMAGE_PNG": return ContentType.IMAGE_PNG; case 1: case "APPLICATION_MD": return ContentType.APPLICATION_MD; case 2: case "APPLICATION_TXT": return ContentType.APPLICATION_TXT; case 3: case "APPLICATION_PDF": return ContentType.APPLICATION_PDF; case 4: case "IMAGE_JPEG": return ContentType.IMAGE_JPEG; case 5: case "IMAGE_WEBP": return ContentType.IMAGE_WEBP; case 6: case "APPLICATION_XLSX": return ContentType.APPLICATION_XLSX; case -1: case "UNRECOGNIZED": default: return ContentType.UNRECOGNIZED; } } export function contentTypeToJSON(object: ContentType): string { switch (object) { case ContentType.IMAGE_PNG: return "IMAGE_PNG"; case ContentType.APPLICATION_MD: return "APPLICATION_MD"; case ContentType.APPLICATION_TXT: return "APPLICATION_TXT"; case ContentType.APPLICATION_PDF: return "APPLICATION_PDF"; case ContentType.IMAGE_JPEG: return "IMAGE_JPEG"; case ContentType.IMAGE_WEBP: return "IMAGE_WEBP"; case ContentType.APPLICATION_XLSX: return "APPLICATION_XLSX"; case ContentType.UNRECOGNIZED: default: return "UNRECOGNIZED"; } } /** Document with metadata and content */ export interface Document { /** Document ID (only for Get/Update/Delete). */ id: string; /** Project this document belongs to. */ projectId: string; /** Document name/title. */ name: string; /** Content type. */ contentType: ContentType; /** Original filename. */ filename: string; /** Optional description. */ description: string; /** Raw document content (bytes) */ data: Uint8Array; /** Read-only fields (returned by server, ignored on Add/Update): */ history: History | undefined; intentIds: string[]; processingStatus: ProcessingStatus | undefined; chunkCount: number; fileSize: number; contentHash: string; contentPreview: string; } /** Processing status. */ export interface ProcessingStatus { status: ProcessingStatus_Status; progress: number; errorMessage: string; lastUpdated: string; } export enum ProcessingStatus_Status { PENDING = 0, PROCESSING = 1, COMPLETED = 2, FAILED = 3, UNRECOGNIZED = -1, } export function processingStatus_StatusFromJSON(object: any): ProcessingStatus_Status { switch (object) { case 0: case "PENDING": return ProcessingStatus_Status.PENDING; case 1: case "PROCESSING": return ProcessingStatus_Status.PROCESSING; case 2: case "COMPLETED": return ProcessingStatus_Status.COMPLETED; case 3: case "FAILED": return ProcessingStatus_Status.FAILED; case -1: case "UNRECOGNIZED": default: return ProcessingStatus_Status.UNRECOGNIZED; } } export function processingStatus_StatusToJSON(object: ProcessingStatus_Status): string { switch (object) { case ProcessingStatus_Status.PENDING: return "PENDING"; case ProcessingStatus_Status.PROCESSING: return "PROCESSING"; case ProcessingStatus_Status.COMPLETED: return "COMPLETED"; case ProcessingStatus_Status.FAILED: return "FAILED"; case ProcessingStatus_Status.UNRECOGNIZED: default: return "UNRECOGNIZED"; } } /** Request to add documents. */ export interface AddDocumentsRequest { projectId: string; creatorId: string; /** Documents to add (with data field filled). */ documents: Document[]; autoProcess: boolean; chunkingStrategy: string; /** If true, exclude output messages from vector search (only inputs will be vectorized). */ excludeOutputsFromSearch: boolean; } /** Response from adding documents. */ export interface AddDocumentsResponse { results: AddDocumentsResponse_Result[]; succeeded: number; failed: number; } export interface AddDocumentsResponse_Result { documentId: string; contentHash: string; processingStatus: ProcessingStatus | undefined; error: string; } /** Request to get documents. */ export interface GetDocumentsRequest { projectId: string; /** Filters */ contentTypeFilter: ContentType; statusFilter: ProcessingStatus_Status; documentIds: string[]; /** Pagination */ limit: number; offset: number; /** Include data field in response. */ includeData: boolean; /** Set to true when content_type_filter is explicitly set (needed because enum default 0 = IMAGE_PNG). */ hasContentTypeFilter: boolean; /** Set to true when status_filter is explicitly set (needed because enum default 0 = PENDING). */ hasStatusFilter: boolean; } /** Response with documents. */ export interface GetDocumentsResponse { documents: Document[]; totalCount: number; } /** Request to process documents into intents. */ export interface ProcessDocumentsRequest { projectId: string; documentIds: string[]; chunkingStrategy: string; batchSize: number; forceReprocess: boolean; /** If true, exclude output messages from vector search (only inputs will be vectorized). */ excludeOutputsFromSearch: boolean; } /** Response from processing. */ export interface ProcessDocumentsResponse { results: ProcessDocumentsResponse_Result[]; succeeded: number; failed: number; } export interface ProcessDocumentsResponse_Result { documentId: string; intentsCreated: number; intentIds: string[]; processingStatus: ProcessingStatus | undefined; error: string; } /** * Request to update documents. * Fill data field only if content should be updated. */ export interface UpdateDocumentsRequest { projectId: string; /** Documents to update (id required, fill other fields to update them). */ documents: Document[]; autoReprocess: boolean; deleteOldIntents: boolean; /** If true, exclude output messages from vector search (only inputs will be vectorized). */ excludeOutputsFromSearch: boolean; } /** Response from update. */ export interface UpdateDocumentsResponse { results: UpdateDocumentsResponse_Result[]; succeeded: number; failed: number; } export interface UpdateDocumentsResponse_Result { documentId: string; contentHash: string; processingStatus: ProcessingStatus | undefined; deletedIntentsCount: number; error: string; /** Number of new intents created (if auto_reprocess) */ intentsCreated: number; /** IDs of new intents created (if auto_reprocess) */ intentIds: string[]; } /** Request to remove documents. */ export interface RemoveDocumentsRequest { projectId: string; documentIds: string[]; cascadeDelete: boolean; } /** Response from removal. */ export interface RemoveDocumentsResponse { results: RemoveDocumentsResponse_Result[]; succeeded: number; failed: number; } export interface RemoveDocumentsResponse_Result { documentId: string; intentsDeleted: number; error: string; } /** Request to get document status. */ export interface GetDocumentStatusRequest { projectId: string; documentIds: string[]; } /** Response with status. */ export interface GetDocumentStatusResponse { statuses: GetDocumentStatusResponse_Status[]; } export interface GetDocumentStatusResponse_Status { documentId: string; processingStatus: ProcessingStatus | undefined; intentsCreated: number; intentIds: string[]; } function createBaseDocument(): Document { return { id: "", projectId: "", name: "", contentType: 0, filename: "", description: "", data: new Uint8Array(0), history: undefined, intentIds: [], processingStatus: undefined, chunkCount: 0, fileSize: 0, contentHash: "", contentPreview: "", }; } export const Document: MessageFns<Document> = { encode(message: Document, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { if (message.id !== "") { writer.uint32(10).string(message.id); } if (message.projectId !== "") { writer.uint32(18).string(message.projectId); } if (message.name !== "") { writer.uint32(26).string(message.name); } if (message.contentType !== 0) { writer.uint32(32).int32(message.contentType); } if (message.filename !== "") { writer.uint32(42).string(message.filename); } if (message.description !== "") { writer.uint32(50).string(message.description); } if (message.data.length !== 0) { writer.uint32(58).bytes(message.data); } if (message.history !== undefined) { History.encode(message.history, writer.uint32(66).fork()).join(); } for (const v of message.intentIds) { writer.uint32(74).string(v!); } if (message.processingStatus !== undefined) { ProcessingStatus.encode(message.processingStatus, writer.uint32(82).fork()).join(); } if (message.chunkCount !== 0) { writer.uint32(88).int32(message.chunkCount); } if (message.fileSize !== 0) { writer.uint32(96).int64(message.fileSize); } if (message.contentHash !== "") { writer.uint32(106).string(message.contentHash); } if (message.contentPreview !== "") { writer.uint32(114).string(message.contentPreview); } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): Document { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); const end = length === undefined ? reader.len : reader.pos + length; const message = createBaseDocument(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 10) { break; } message.id = reader.string(); continue; } case 2: { if (tag !== 18) { break; } message.projectId = reader.string(); continue; } case 3: { if (tag !== 26) { break; } message.name = reader.string(); continue; } case 4: { if (tag !== 32) { break; } message.contentType = reader.int32() as any; continue; } case 5: { if (tag !== 42) { break; } message.filename = reader.string(); continue; } case 6: { if (tag !== 50) { break; } message.description = reader.string(); continue; } case 7: { if (tag !== 58) { break; } message.data = reader.bytes(); continue; } case 8: { if (tag !== 66) { break; } message.history = History.decode(reader, reader.uint32()); continue; } case 9: { if (tag !== 74) { break; } message.intentIds.push(reader.string()); continue; } case 10: { if (tag !== 82) { break; } message.processingStatus = ProcessingStatus.decode(reader, reader.uint32()); continue; } case 11: { if (tag !== 88) { break; } message.chunkCount = reader.int32(); continue; } case 12: { if (tag !== 96) { break; } message.fileSize = longToNumber(reader.int64()); continue; } case 13: { if (tag !== 106) { break; } message.contentHash = reader.string(); continue; } case 14: { if (tag !== 114) { break; } message.contentPreview = reader.string(); continue; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; }, fromJSON(object: any): Document { return { id: isSet(object.id) ? globalThis.String(object.id) : "", projectId: isSet(object.projectId) ? globalThis.String(object.projectId) : isSet(object.project_id) ? globalThis.String(object.project_id) : "", name: isSet(object.name) ? globalThis.String(object.name) : "", contentType: isSet(object.contentType) ? contentTypeFromJSON(object.contentType) : isSet(object.content_type) ? contentTypeFromJSON(object.content_type) : 0, filename: isSet(object.filename) ? globalThis.String(object.filename) : "", description: isSet(object.description) ? globalThis.String(object.description) : "", data: isSet(object.data) ? bytesFromBase64(object.data) : new Uint8Array(0), history: isSet(object.history) ? History.fromJSON(object.history) : undefined, intentIds: globalThis.Array.isArray(object?.intentIds) ? object.intentIds.map((e: any) => globalThis.String(e)) : globalThis.Array.isArray(object?.intent_ids) ? object.intent_ids.map((e: any) => globalThis.String(e)) : [], processingStatus: isSet(object.processingStatus) ? ProcessingStatus.fromJSON(object.processingStatus) : isSet(object.processing_status) ? ProcessingStatus.fromJSON(object.processing_status) : undefined, chunkCount: isSet(object.chunkCount) ? globalThis.Number(object.chunkCount) : isSet(object.chunk_count) ? globalThis.Number(object.chunk_count) : 0, fileSize: isSet(object.fileSize) ? globalThis.Number(object.fileSize) : isSet(object.file_size) ? globalThis.Number(object.file_size) : 0, contentHash: isSet(object.contentHash) ? globalThis.String(object.contentHash) : isSet(object.content_hash) ? globalThis.String(object.content_hash) : "", contentPreview: isSet(object.contentPreview) ? globalThis.String(object.contentPreview) : isSet(object.content_preview) ? globalThis.String(object.content_preview) : "", }; }, toJSON(message: Document): unknown { const obj: any = {}; if (message.id !== "") { obj.id = message.id; } if (message.projectId !== "") { obj.projectId = message.projectId; } if (message.name !== "") { obj.name = message.name; } if (message.contentType !== 0) { obj.contentType = contentTypeToJSON(message.contentType); } if (message.filename !== "") { obj.filename = message.filename; } if (message.description !== "") { obj.description = message.description; } if (message.data.length !== 0) { obj.data = base64FromBytes(message.data); } if (message.history !== undefined) { obj.history = History.toJSON(message.history); } if (message.intentIds?.length) { obj.intentIds = message.intentIds; } if (message.processingStatus !== undefined) { obj.processingStatus = ProcessingStatus.toJSON(message.processingStatus); } if (message.chunkCount !== 0) { obj.chunkCount = Math.round(message.chunkCount); } if (message.fileSize !== 0) { obj.fileSize = Math.round(message.fileSize); } if (message.contentHash !== "") { obj.contentHash = message.contentHash; } if (message.contentPreview !== "") { obj.contentPreview = message.contentPreview; } return obj; }, create<I extends Exact<DeepPartial<Document>, I>>(base?: I): Document { return Document.fromPartial(base ?? ({} as any)); }, fromPartial<I extends Exact<DeepPartial<Document>, I>>(object: I): Document { const message = createBaseDocument(); message.id = object.id ?? ""; message.projectId = object.projectId ?? ""; message.name = object.name ?? ""; message.contentType = object.contentType ?? 0; message.filename = object.filename ?? ""; message.description = object.description ?? ""; message.data = object.data ?? new Uint8Array(0); message.history = (object.history !== undefined && object.history !== null) ? History.fromPartial(object.history) : undefined; message.intentIds = object.intentIds?.map((e) => e) || []; message.processingStatus = (object.processingStatus !== undefined && object.processingStatus !== null) ? ProcessingStatus.fromPartial(object.processingStatus) : undefined; message.chunkCount = object.chunkCount ?? 0; message.fileSize = object.fileSize ?? 0; message.contentHash = object.contentHash ?? ""; message.contentPreview = object.contentPreview ?? ""; return message; }, }; function createBaseProcessingStatus(): ProcessingStatus { return { status: 0, progress: 0, errorMessage: "", lastUpdated: "" }; } export const ProcessingStatus: MessageFns<ProcessingStatus> = { encode(message: ProcessingStatus, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { if (message.status !== 0) { writer.uint32(8).int32(message.status); } if (message.progress !== 0) { writer.uint32(16).int32(message.progress); } if (message.errorMessage !== "") { writer.uint32(26).string(message.errorMessage); } if (message.lastUpdated !== "") { writer.uint32(34).string(message.lastUpdated); } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): ProcessingStatus { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); const end = length === undefined ? reader.len : reader.pos + length; const message = createBaseProcessingStatus(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 8) { break; } message.status = reader.int32() as any; continue; } case 2: { if (tag !== 16) { break; } message.progress = reader.int32(); continue; } case 3: { if (tag !== 26) { break; } message.errorMessage = reader.string(); continue; } case 4: { if (tag !== 34) { break; } message.lastUpdated = reader.string(); continue; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; }, fromJSON(object: any): ProcessingStatus { return { status: isSet(object.status) ? processingStatus_StatusFromJSON(object.status) : 0, progress: isSet(object.progress) ? globalThis.Number(object.progress) : 0, errorMessage: isSet(object.errorMessage) ? globalThis.String(object.errorMessage) : isSet(object.error_message) ? globalThis.String(object.error_message) : "", lastUpdated: isSet(object.lastUpdated) ? globalThis.String(object.lastUpdated) : isSet(object.last_updated) ? globalThis.String(object.last_updated) : "", }; }, toJSON(message: ProcessingStatus): unknown { const obj: any = {}; if (message.status !== 0) { obj.status = processingStatus_StatusToJSON(message.status); } if (message.progress !== 0) { obj.progress = Math.round(message.progress); } if (message.errorMessage !== "") { obj.errorMessage = message.errorMessage; } if (message.lastUpdated !== "") { obj.lastUpdated = message.lastUpdated; } return obj; }, create<I extends Exact<DeepPartial<ProcessingStatus>, I>>(base?: I): ProcessingStatus { return ProcessingStatus.fromPartial(base ?? ({} as any)); }, fromPartial<I extends Exact<DeepPartial<ProcessingStatus>, I>>(object: I): ProcessingStatus { const message = createBaseProcessingStatus(); message.status = object.status ?? 0; message.progress = object.progress ?? 0; message.errorMessage = object.errorMessage ?? ""; message.lastUpdated = object.lastUpdated ?? ""; return message; }, }; function createBaseAddDocumentsRequest(): AddDocumentsRequest { return { projectId: "", creatorId: "", documents: [], autoProcess: false, chunkingStrategy: "", excludeOutputsFromSearch: false, }; } export const AddDocumentsRequest: MessageFns<AddDocumentsRequest> = { encode(message: AddDocumentsRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { if (message.projectId !== "") { writer.uint32(10).string(message.projectId); } if (message.creatorId !== "") { writer.uint32(18).string(message.creatorId); } for (const v of message.documents) { Document.encode(v!, writer.uint32(26).fork()).join(); } if (message.autoProcess !== false) { writer.uint32(32).bool(message.autoProcess); } if (message.chunkingStrategy !== "") { writer.uint32(42).string(message.chunkingStrategy); } if (message.excludeOutputsFromSearch !== false) { writer.uint32(48).bool(message.excludeOutputsFromSearch); } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): AddDocumentsRequest { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); const end = length === undefined ? reader.len : reader.pos + length; const message = createBaseAddDocumentsRequest(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 10) { break; } message.projectId = reader.string(); continue; } case 2: { if (tag !== 18) { break; } message.creatorId = reader.string(); continue; } case 3: { if (tag !== 26) { break; } message.documents.push(Document.decode(reader, reader.uint32())); continue; } case 4: { if (tag !== 32) { break; } message.autoProcess = reader.bool(); continue; } case 5: { if (tag !== 42) { break; } message.chunkingStrategy = reader.string(); continue; } case 6: { if (tag !== 48) { break; } message.excludeOutputsFromSearch = reader.bool(); continue; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; }, fromJSON(object: any): AddDocumentsRequest { return { projectId: isSet(object.projectId) ? globalThis.String(object.projectId) : isSet(object.project_id) ? globalThis.String(object.project_id) : "", creatorId: isSet(object.creatorId) ? globalThis.String(object.creatorId) : isSet(object.creator_id) ? globalThis.String(object.creator_id) : "", documents: globalThis.Array.isArray(object?.documents) ? object.documents.map((e: any) => Document.fromJSON(e)) : [], autoProcess: isSet(object.autoProcess) ? globalThis.Boolean(object.autoProcess) : isSet(object.auto_process) ? globalThis.Boolean(object.auto_process) : false, chunkingStrategy: isSet(object.chunkingStrategy) ? globalThis.String(object.chunkingStrategy) : isSet(object.chunking_strategy) ? globalThis.String(object.chunking_strategy) : "", excludeOutputsFromSearch: isSet(object.excludeOutputsFromSearch) ? globalThis.Boolean(object.excludeOutputsFromSearch) : isSet(object.exclude_outputs_from_search) ? globalThis.Boolean(object.exclude_outputs_from_search) : false, }; }, toJSON(message: AddDocumentsRequest): unknown { const obj: any = {}; if (message.projectId !== "") { obj.projectId = message.projectId; } if (message.creatorId !== "") { obj.creatorId = message.creatorId; } if (message.documents?.length) { obj.documents = message.documents.map((e) => Document.toJSON(e)); } if (message.autoProcess !== false) { obj.autoProcess = message.autoProcess; } if (message.chunkingStrategy !== "") { obj.chunkingStrategy = message.chunkingStrategy; } if (message.excludeOutputsFromSearch !== false) { obj.excludeOutputsFromSearch = message.excludeOutputsFromSearch; } return obj; }, create<I extends Exact<DeepPartial<AddDocumentsRequest>, I>>(base?: I): AddDocumentsRequest { return AddDocumentsRequest.fromPartial(base ?? ({} as any)); }, fromPartial<I extends Exact<DeepPartial<AddDocumentsRequest>, I>>(object: I): AddDocumentsRequest { const message = createBaseAddDocumentsRequest(); message.projectId = object.projectId ?? ""; message.creatorId = object.creatorId ?? ""; message.documents = object.documents?.map((e) => Document.fromPartial(e)) || []; message.autoProcess = object.autoProcess ?? false; message.chunkingStrategy = object.chunkingStrategy ?? ""; message.excludeOutputsFromSearch = object.excludeOutputsFromSearch ?? false; return message; }, }; function createBaseAddDocumentsResponse(): AddDocumentsResponse { return { results: [], succeeded: 0, failed: 0 }; } export const AddDocumentsResponse: MessageFns<AddDocumentsResponse> = { encode(message: AddDocumentsResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { for (const v of message.results) { AddDocumentsResponse_Result.encode(v!, writer.uint32(10).fork()).join(); } if (message.succeeded !== 0) { writer.uint32(16).int32(message.succeeded); } if (message.failed !== 0) { writer.uint32(24).int32(message.failed); } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): AddDocumentsResponse { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); const end = length === undefined ? reader.len : reader.pos + length; const message = createBaseAddDocumentsResponse(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 10) { break; } message.results.push(AddDocumentsResponse_Result.decode(reader, reader.uint32())); continue; } case 2: { if (tag !== 16) { break; } message.succeeded = reader.int32(); continue; } case 3: { if (tag !== 24) { break; } message.failed = reader.int32(); continue; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; }, fromJSON(object: any): AddDocumentsResponse { return { results: globalThis.Array.isArray(object?.results) ? object.results.map((e: any) => AddDocumentsResponse_Result.fromJSON(e)) : [], succeeded: isSet(object.succeeded) ? globalThis.Number(object.succeeded) : 0, failed: isSet(object.failed) ? globalThis.Number(object.failed) : 0, }; }, toJSON(message: AddDocumentsResponse): unknown { const obj: any = {}; if (message.results?.length) { obj.results = message.results.map((e) => AddDocumentsResponse_Result.toJSON(e)); } if (message.succeeded !== 0) { obj.succeeded = Math.round(message.succeeded); } if (message.failed !== 0) { obj.failed = Math.round(message.failed); } return obj; }, create<I extends Exact<DeepPartial<AddDocumentsResponse>, I>>(base?: I): AddDocumentsResponse { return AddDocumentsResponse.fromPartial(base ?? ({} as any)); }, fromPartial<I extends Exact<DeepPartial<AddDocumentsResponse>, I>>(object: I): AddDocumentsResponse { const message = createBaseAddDocumentsResponse(); message.results = object.results?.map((e) => AddDocumentsResponse_Result.fromPartial(e)) || []; message.succeeded = object.succeeded ?? 0; message.failed = object.failed ?? 0; return message; }, }; function createBaseAddDocumentsResponse_Result(): AddDocumentsResponse_Result { return { documentId: "", contentHash: "", processingStatus: undefined, error: "" }; } export const AddDocumentsResponse_Result: MessageFns<AddDocumentsResponse_Result> = { encode(message: AddDocumentsResponse_Result, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { if (message.documentId !== "") { writer.uint32(10).string(message.documentId); } if (message.contentHash !== "") { writer.uint32(18).string(message.contentHash); } if (message.processingStatus !== undefined) { ProcessingStatus.encode(message.processingStatus, writer.uint32(26).fork()).join(); } if (message.error !== "") { writer.uint32(34).string(message.error); } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): AddDocumentsResponse_Result { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); const end = length === undefined ? reader.len : reader.pos + length; const message = createBaseAddDocumentsResponse_Result(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 10) { break; } message.documentId = reader.string(); continue; } case 2: { if (tag !== 18) { break; } message.contentHash = reader.string(); continue; } case 3: { if (tag !== 26) { break; } message.processingStatus = ProcessingStatus.decode(reader, reader.uint32()); continue; } case 4: { if (tag !== 34) { break; } message.error = reader.string(); continue; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; }, fromJSON(object: any): AddDocumentsResponse_Result { return { documentId: isSet(object.documentId) ? globalThis.String(object.documentId) : isSet(object.document_id) ? globalThis.String(object.document_id) : "", contentHash: isSet(object.contentHash) ? globalThis.String(object.contentHash) : isSet(object.content_hash) ? globalThis.String(object.content_hash) : "", processingStatus: isSet(object.processingStatus) ? ProcessingStatus.fromJSON(object.processingStatus) : isSet(object.processing_status) ? ProcessingStatus.fromJSON(object.processing_status) : undefined, error: isSet(object.error) ? globalThis.String(object.error) : "", }; }, toJSON(message: AddDocumentsResponse_Result): unknown { const obj: any = {}; if (message.documentId !== "") { obj.documentId = message.documentId; } if (message.contentHash !== "") { obj.contentHash = message.contentHash; } if (message.processingStatus !== undefined) { obj.processingStatus = ProcessingStatus.toJSON(message.processingStatus); } if (message.error !== "") { obj.error = message.error; } return obj; }, create<I extends Exact<DeepPartial<AddDocumentsResponse_Result>, I>>(base?: I): AddDocumentsResponse_Result { return AddDocumentsResponse_Result.fromPartial(base ?? ({} as any)); }, fromPartial<I extends Exact<DeepPartial<AddDocumentsResponse_Result>, I>>(object: I): AddDocumentsResponse_Result { const message = createBaseAddDocumentsResponse_Result(); message.documentId = object.documentId ?? ""; message.contentHash = object.contentHash ?? ""; message.processingStatus = (object.processingStatus !== undefined && object.processingStatus !== null) ? ProcessingStatus.fromPartial(object.processingStatus) : undefined; message.error = object.error ?? ""; return message; }, }; function createBaseGetDocumentsRequest(): GetDocumentsRequest { return { projectId: "", contentTypeFilter: 0, statusFilter: 0, documentIds: [], limit: 0, offset: 0, includeData: false, hasContentTypeFilter: false, hasStatusFilter: false, }; } export const GetDocumentsRequest: MessageFns<GetDocumentsRequest> = { encode(message: GetDocumentsRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { if (message.projectId !== "") { writer.uint32(10).string(message.projectId); } if (message.contentTypeFilter !== 0) { writer.uint32(16).int32(message.contentTypeFilter); } if (message.statusFilter !== 0) { writer.uint32(24).int32(message.statusFilter); } for (const v of message.documentIds) { writer.uint32(34).string(v!); } if (message.limit !== 0) { writer.uint32(40).int32(message.limit); } if (message.offset !== 0) { writer.uint32(48).int32(message.offset); } if (message.includeData !== false) { writer.uint32(56).bool(message.includeData); } if (message.hasContentTypeFilter !== false) { writer.uint32(64).bool(message.hasContentTypeFilter); } if (message.hasStatusFilter !== false) { writer.uint32(72).bool(message.hasStatusFilter); } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): GetDocumentsRequest { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); const end = length === undefined ? reader.len : reader.pos + length; const message = createBaseGetDocumentsRequest(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 10) { break; } message.projectId = reader.string(); continue; } case 2: { if (tag !== 16) { break; } message.contentTypeFilter = reader.int32() as any; continue; } case 3: { if (tag !== 24) { break; } message.statusFilter = reader.int32() as any; continue; } case 4: { if (tag !== 34) { break; } message.documentIds.push(reader.string()); continue; } case 5: { if (tag !== 40) { break; } message.limit = reader.int32(); continue; } case 6: { if (tag !== 48) { break; } message.offset = reader.int32(); continue; } case 7: { if (tag !== 56) { break; } message.includeData = reader.bool(); continue; } case 8: { if (tag !== 64) { break; } message.hasContentTypeFilter = reader.bool(); continue; } case 9: { if (tag !== 72) { break; } message.hasStatusFilter = reader.bool(); continue; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; }, fromJSON(object: any): GetDocumentsRequest { return { projectId: isSet(object.projectId) ? globalThis.String(object.projectId) : isSet(object.project_id) ? globalThis.String(object.project_id) : "", contentTypeFilter: isSet(object.contentTypeFilter) ? contentTypeFromJSON(object.contentTypeFilter) : isSet(object.content_type_filter) ? contentTypeFromJSON(object.content_type_filter) : 0, statusFilter: isSet(object.statusFilter) ? processingStatus_StatusFromJSON(object.statusFilter) : isSet(object.status_filter) ? processingStatus_StatusFromJSON(object.status_filter) : 0, documentIds: globalThis.Array.isArray(object?.documentIds) ? object.documentIds.map((e: any) => globalThis.String(e)) : globalThis.Array.isArray(object?.document_ids) ? object.document_ids.map((e: any) => globalThis.String(e)) : [], limit: isSet(object.limit) ? globalThis.Number(object.limit) : 0, offset: isSet(object.offset) ? globalThis.Number(object.offset) : 0, includeData: isSet(object.includeData) ? globalThis.Boolean(object.includeData) : isSet(object.include_data) ? globalThis.Boolean(object.include_data) : false, hasContentTypeFilter: isSet(object.hasContentTypeFilter) ? globalThis.Boolean(object.hasContentTypeFilter) : isSet(object.has_content_type_filter) ? globalThis.Boolean(object.has_content_type_filter) : false, hasStatusFilter: isSet(object.hasStatusFilter) ? globalThis.Boolean(object.hasStatusFilter) : isSet(object.has_status_filter) ? globalThis.Boolean(object.has_status_filter) : false, }; }, toJSON(message: GetDocumentsRequest): unknown { const obj: any = {}; if (message.projectId !== "") { obj.projectId = message.projectId; } if (message.contentTypeFilter !== 0) { obj.contentTypeFilter = contentTypeToJSON(message.contentTypeFilter); } if (message.statusFilter !== 0) { obj.statusFilter = processingStatus_StatusToJSON(message.statusFilter); } if (message.documentIds?.length) { obj.documentIds = message.documentIds; } if (message.limit !== 0) { obj.limit = Math.round(message.limit); } if (message.offset !== 0) { obj.offset = Math.round(message.offset); } if (message.includeData !== false) { obj.includeData = message.includeData; } if (message.hasContentTypeFilter !== false) { obj.hasContentTypeFilter = message.hasContentTypeFilter; } if (message.hasStatusFilter !== false) { obj.hasStatusFilter = message.hasStatusFilter; } return obj; }, create<I extends Exact<DeepPartial<GetDocumentsRequest>, I>>(base?: I): GetDocumentsRequest { return GetDocumentsRequest.fromPartial(base ?? ({} as any)); }, fromPartial<I extends Exact<DeepPartial<GetDocumentsRequest>, I>>(object: I): GetDocumentsRequest { const message = createBaseGetDocumentsRequest(); message.projectId = object.projectId ?? ""; message.contentTypeFilter = object.contentTypeFilter ?? 0; message.statusFilter = object.statusFilter ?? 0; message.documentIds = object.documentIds?.map((e) => e) || []; message.limit = object.limit ?? 0; message.offset = object.offset ?? 0; message.includeData = object.includeData ?? false; message.hasContentTypeFilter = object.hasContentTypeFilter ?? false; message.hasStatusFilter = object.hasStatusFilter ?? false; return message; }, }; function createBaseGetDocumentsResponse(): GetDocumentsResponse { return { documents: [], totalCount: 0 }; } export const GetDocumentsResponse: MessageFns<GetDocumentsResponse> = { encode(message: GetDocumentsResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { for (const v of message.documents) { Document.encode(v!, writer.uint32(10).fork()).join(); } if (message.totalCount !== 0) { writer.uint32(16).int32(message.totalCount); } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): GetDocumentsResponse { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); const end = length === undefined ? reader.len : reader.pos + length; const message = createBaseGetDocumentsResponse(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 10) { break; } message.documents.push(Document.decode(reader, reader.uint32())); continue; } case 2: { if (tag !== 16) { break; } message.totalCount = reader.int32(); continue; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; }, fromJSON(object: any): GetDocumentsResponse { return { documents: globalThis.Array.isArray(object?.documents) ? object.documents.map((e: any) => Document.fromJSON(e)) : [], totalCount: isSet(object.totalCount) ? globalThis.Number(object.totalCount) : isSet(object.total_count) ? globalThis.Number(object.total_count) : 0, }; }, toJSON(message: GetDocumentsResponse): unknown { const obj: any = {}; if (message.documents?.length) { obj.documents = message.documents.map((e) => Document.toJSON(e)); } if (message.totalCount !== 0) { obj.totalCount = Math.round(message.totalCount); } return obj; }, create<I extends Exact<DeepPartial<GetDocumentsResponse>, I>>(base?: I): GetDocumentsResponse { return GetDocumentsResponse.fromPartial(base ?? ({} as any)); }, fromPartial<I extends Exact<DeepPartial<GetDocumentsResponse>, I>>(object: I): GetDocumentsResponse { const message = createBaseGetDocumentsResponse(); message.documents = object.documents?.map((e) => Document.fromPartial(e)) || []; message.totalCount = object.totalCount ?? 0; return message; }, }; function createBaseProcessDocumentsRequest(): ProcessDocumentsRequest { return { projectId: "", documentIds: [], chunkingStrategy: "", batchSize: 0, forceReprocess: false, excludeOutputsFromSearch: false, }; } export const ProcessDocumentsRequest: MessageFns<ProcessDocumentsRequest> = { encode(message: ProcessDocumentsRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { if (message.projectId !== "") { writer.uint32(10).string(message.projectId); } for (const v of message.documentIds) { writer.uint32(18).string(v!); } if (message.chunkingStrategy !== "") { writer.uint32(26).string(message.chunkingStrategy); } if (message.batchSize !== 0) { writer.uint32(32).int32(message.batchSize); } if (message.forceReprocess !== false) { writer.uint32(40).bool(message.forceReprocess); } if (message.excludeOutputsFromSearch !== false) { writer.uint32(48).bool(message.excludeOutputsFromSearch); } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): ProcessDocumentsRequest { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); const end = length === undefined ? reader.len : reader.pos + length; const message = createBaseProcessDocumentsRequest(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 10) { break; } message.projectId = reader.string(); continue; } case 2: { if (tag !== 18) { break; } message.documentIds.push(reader.string()); continue; } case 3: { if (tag !== 26) { break; } message.chunkingStrategy = reader.string(); continue; } case 4: { if (tag !== 32) { break; } message.batchSize = reader.int32(); continue; } case 5: { if (tag !== 40) { break; } message.forceReprocess = reader.bool(); continue; } case 6: { if (tag !== 48) { break; } message.excludeOutputsFromSearch = reader.bool(); continue; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; }, fromJSON(object: any): ProcessDocumentsRequest { return { projectId: isSet(object.projectId) ? globalThis.String(object.projectId) : isSet(object.project_id) ? globalThis.String(object.project_id) : "", documentIds: globalThis.Array.isArray(object?.documentIds) ? object.documentIds.map((e: any) => globalThis.String(e)) : globalThis.Array.isArray(object?.document_ids) ? object.document_ids.map((e: any) => globalThis.String(e)) : [], chunkingStrategy: isSet(object.chunkingStrategy) ? globalThis.String(object.chunkingStrategy) : isSet(object.chunking_strategy) ? globalThis.String(object.chunking_strategy) : "", batchSize: isSet(object.batchSize) ? globalThis.Number(object.batchSize) : isSet(object.batch_size) ? globalThis.Number(object.batch_size) : 0, forceReprocess: isSet(object.forceReprocess) ? globalThis.Boolean(object.forceReprocess) : isSet(object.force_reprocess) ? globalThis.Boolean(object.force_reprocess) : false, excludeOutputsFromSearch: isSet(object.excludeOutputsFromSearch) ? globalThis.Boolean(object.excludeOutputsFromSearch) : isSet(object.exclude_outputs_from_search) ? globalThis.Boolean(object.exclude_outputs_from_search) : false, }; }, toJSON(message: ProcessDocumentsRequest): unknown { const obj: any = {}; if (message.projectId !== "") { obj.projectId = message.projectId; } if (message.documentIds?.length) { obj.documentIds = message.documentIds; } if (message.chunkingStrategy !== "") { obj.chunkingStrategy = message.chunkingStrategy; } if (message.batchSize !== 0) { obj.batchSize = Math.round(message.batchSize); } if (message.forceReprocess !== false) { obj.forceReprocess = message.forceReprocess; } if (message.excludeOutputsFromSearch !== false) { obj.excludeOutputsFromSearch = message.excludeOutputsFromSearch; } return obj; }, create<I extends Exact<DeepPartial<ProcessDocumentsRequest>, I>>(base?: I): ProcessDocumentsRequest { return ProcessDocumentsRequest.fromPartial(base ?? ({} as any)); }, fromPartial<I extends Exact<DeepPartial<ProcessDocumentsRequest>, I>>(object: I): ProcessDocumentsRequest { const message = createBaseProcessDocumentsRequest(); message.projectId = object.projectId ?? ""; message.documentIds = object.documentIds?.map((e) => e) || []; message.chunkingStrategy = object.chunkingStrategy ?? ""; message.batchSize = object.batchSize ?? 0; message.forceReprocess = object.forceReprocess ?? false; message.excludeOutputsFromSearch = object.excludeOutputsFromSearch ?? false; return message; }, }; function createBaseProcessDocumentsResponse(): ProcessDocumentsResponse { return { results: [], succeeded: 0, failed: 0 }; } export const ProcessDocumentsResponse: MessageFns<ProcessDocumentsResponse> = { encode(message: ProcessDocumentsResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { for (const v of message.results) { ProcessDocumentsResponse_Result.encode(v!, writer.uint32(10).fork()).join(); } if (message.succeeded !== 0) { writer.uint32(16).int32(message.succeeded); } if (message.failed !== 0) { writer.uint32(24).int32(message.failed); } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): ProcessDocumentsResponse { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); const end = length === undefined ? reader.len : reader.pos + length; const message = createBaseProcessDocumentsResponse(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 10) { break; } message.results.push(ProcessDocumentsResponse_Result.decode(reader, reader.uint32())); continue; } case 2: { if (tag !== 16) { break; } message.succeeded = reader.int32(); continue; } case 3: { if (tag !== 24) { break; } message.failed = reader.int32(); continue; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; }, fromJSON(object: any): ProcessDocumentsResponse { return { results: globalThis.Array.isArray(object?.results) ? object.results.map((e: any) => ProcessDocumentsResponse_Result.fromJSON(e)) : [], succeeded: isSet(object.succeeded) ? globalThis.Number(object.succeeded) : 0, failed: isSet(object.failed) ? globalThis.Number(object.failed) : 0, }; }, toJSON(message: ProcessDocumentsResponse): unknown { const obj: any = {}; if (message.results?.length) {