56 lines
1.5 KiB
TypeScript

import { JSONArray, JSONObject, searchJSON } from "../../lib/JSONSearch/jsonSearch.ts";
export interface ISchema {
name: string;
accolades: any; // TODO - populate with accolades schema type
publicationRules: {
name: string;
isExtensible: boolean;
// overwrites: boolean;
canExtend: boolean;
reviewRequired: boolean;
corrections: {
reviewRequired: boolean;
preserveHistory: boolean;
}
}[]
allowsListBuilding: boolean;
listBuildingRules: any; // TODO - populate with list building rules schema type
schemaProperties: Record<string, any>;
}
// export type searchString = `${/[a-z]/i}`
export class GameSystemSchema<T extends JSONObject | JSONArray> implements ISchema {
name: string;
accolades: any;
publicationRules: {
name: string;
isExtensible: boolean;
// overwrites: boolean;
canExtend: boolean;
reviewRequired: boolean;
corrections: {
reviewRequired: boolean;
preserveHistory: boolean;
};
}[];
allowsListBuilding: boolean;
listBuildingRules: any;
schemaProperties: Record<string, any>;
constructor(schemaJson: ISchema) {
this.name = schemaJson.name;
this.accolades = schemaJson.accolades;
this.publicationRules = schemaJson.publicationRules;
this.allowsListBuilding = schemaJson.allowsListBuilding;
this.listBuildingRules = schemaJson.listBuildingRules;
this.schemaProperties = schemaJson.schemaProperties;
}
search(search: string, values: T) {
return searchJSON(values, search);
}
}