feat(laws,opendata): add local law storage and migrate OpenData persistence to smartdb-backed local storage
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
import * as plugins from '../plugins.js';
|
||||
import type { TJurisdiction, TLawSource, TRawLawFormat } from './interfaces.law.js';
|
||||
|
||||
@plugins.smartdata.Manager()
|
||||
export class LawRecord extends plugins.smartdata.SmartDataDbDoc<LawRecord, LawRecord> {
|
||||
public static getByLookupKey = async (lookupKeyArg: string) => {
|
||||
const lawRecords = await LawRecord.getInstances({
|
||||
lookupKey: lookupKeyArg,
|
||||
});
|
||||
return lawRecords[0];
|
||||
};
|
||||
|
||||
@plugins.smartdata.unI()
|
||||
id!: string;
|
||||
|
||||
@plugins.smartdata.unI()
|
||||
@plugins.smartdata.svDb()
|
||||
lookupKey!: string;
|
||||
|
||||
@plugins.smartdata.index()
|
||||
@plugins.smartdata.svDb()
|
||||
jurisdiction!: TJurisdiction;
|
||||
|
||||
@plugins.smartdata.index()
|
||||
@plugins.smartdata.svDb()
|
||||
source!: TLawSource;
|
||||
|
||||
@plugins.smartdata.searchable()
|
||||
@plugins.smartdata.svDb()
|
||||
identifier!: string;
|
||||
|
||||
@plugins.smartdata.searchable()
|
||||
@plugins.smartdata.svDb()
|
||||
title!: string;
|
||||
|
||||
@plugins.smartdata.searchable()
|
||||
@plugins.smartdata.svDb()
|
||||
shortTitle: string = '';
|
||||
|
||||
@plugins.smartdata.searchable()
|
||||
@plugins.smartdata.svDb()
|
||||
citation: string = '';
|
||||
|
||||
@plugins.smartdata.index()
|
||||
@plugins.smartdata.svDb()
|
||||
type: string = '';
|
||||
|
||||
@plugins.smartdata.index()
|
||||
@plugins.smartdata.svDb()
|
||||
language: string = '';
|
||||
|
||||
@plugins.smartdata.svDb()
|
||||
sourceUrl!: string;
|
||||
|
||||
@plugins.smartdata.svDb()
|
||||
rawFormat!: TRawLawFormat;
|
||||
|
||||
@plugins.smartdata.svDb()
|
||||
rawBody!: string;
|
||||
|
||||
@plugins.smartdata.searchable()
|
||||
@plugins.smartdata.svDb()
|
||||
text!: string;
|
||||
|
||||
@plugins.smartdata.index()
|
||||
@plugins.smartdata.svDb()
|
||||
dateIssued: string = '';
|
||||
|
||||
@plugins.smartdata.index()
|
||||
@plugins.smartdata.svDb()
|
||||
lastModified: string = '';
|
||||
|
||||
@plugins.smartdata.svDb()
|
||||
sourceMeta: Record<string, string> = {};
|
||||
|
||||
@plugins.smartdata.svDb()
|
||||
fetchedAt: Date = new Date();
|
||||
|
||||
@plugins.smartdata.svDb()
|
||||
syncedAt: Date = new Date();
|
||||
}
|
||||
Reference in New Issue
Block a user