Spaces:
Build error
Build error
| import { Also, parseJSONText, Prop } from 'civkit'; | |
| import { FirestoreRecord } from '../shared/lib/firestore'; | |
| import _ from 'lodash'; | |
| ({ | |
| dictOf: Object | |
| }) | |
| export class SearchResult extends FirestoreRecord { | |
| static override collectionName = 'searchResults'; | |
| override _id!: string; | |
| ({ | |
| required: true | |
| }) | |
| query!: any; | |
| ({ | |
| required: true | |
| }) | |
| queryDigest!: string; | |
| () | |
| response?: any; | |
| () | |
| createdAt!: Date; | |
| () | |
| expireAt?: Date; | |
| [k: string]: any; | |
| static patchedFields = [ | |
| 'query', | |
| 'response', | |
| ]; | |
| static override from(input: any) { | |
| for (const field of this.patchedFields) { | |
| if (typeof input[field] === 'string') { | |
| input[field] = parseJSONText(input[field]); | |
| } | |
| } | |
| return super.from(input) as SearchResult; | |
| } | |
| override degradeForFireStore() { | |
| const copy: any = { ...this }; | |
| for (const field of (this.constructor as typeof SearchResult).patchedFields) { | |
| if (typeof copy[field] === 'object') { | |
| copy[field] = JSON.stringify(copy[field]) as any; | |
| } | |
| } | |
| return copy; | |
| } | |
| } | |
| export class SerperSearchResult extends SearchResult { | |
| static override collectionName = 'serperSearchResults'; | |
| } | |
| export class SERPResult extends SearchResult { | |
| static override collectionName = 'SERPResults'; | |
| } |