Honestly way too much went into this single commit. I am so sorry future me
This commit is contained in:
55
game-systems-service/types/schema.ts
Normal file
55
game-systems-service/types/schema.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user