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();
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,3 @@
|
||||
export * from './interfaces.law.js';
|
||||
export * from './classes.lawrecord.js';
|
||||
export * from './classes.lawservice.js';
|
||||
@@ -0,0 +1,48 @@
|
||||
export type TJurisdiction = 'de' | 'eu' | 'us';
|
||||
|
||||
export type TLawSource =
|
||||
| 'gesetze-im-internet'
|
||||
| 'eur-lex'
|
||||
| 'law-cornell-lii'
|
||||
| 'govinfo-plaw'
|
||||
| 'govinfo-uscode';
|
||||
|
||||
export type TRawLawFormat = 'xml' | 'html' | 'text' | 'json';
|
||||
|
||||
export type TUsLawCollection = 'PLAW' | 'USCODE';
|
||||
|
||||
export interface ILawServiceConfig {
|
||||
dbFolderPath?: string;
|
||||
dbName?: string;
|
||||
govInfoApiKey?: string;
|
||||
}
|
||||
|
||||
export interface ILawLookupRequest {
|
||||
jurisdiction: TJurisdiction;
|
||||
identifier: string;
|
||||
language?: string;
|
||||
usCollection?: TUsLawCollection;
|
||||
forceSync?: boolean;
|
||||
}
|
||||
|
||||
export interface ILawSyncRequest {
|
||||
jurisdiction: TJurisdiction;
|
||||
limit?: number;
|
||||
offset?: number;
|
||||
language?: string;
|
||||
govInfoApiKey?: string;
|
||||
usCollection?: TUsLawCollection;
|
||||
since?: Date;
|
||||
}
|
||||
|
||||
export interface ILawSearchRequest {
|
||||
query: string;
|
||||
jurisdiction?: TJurisdiction;
|
||||
limit?: number;
|
||||
}
|
||||
|
||||
export interface ILawSyncResult {
|
||||
jurisdiction: TJurisdiction;
|
||||
syncedCount: number;
|
||||
identifiers: string[];
|
||||
}
|
||||
Reference in New Issue
Block a user