Skip to content

Commit

Permalink
Forgot to merge schema changes to main
Browse files Browse the repository at this point in the history
  • Loading branch information
Perlkonig committed Nov 8, 2023
1 parent 6f39dee commit e42214b
Show file tree
Hide file tree
Showing 7 changed files with 3,570 additions and 417 deletions.
3,933 changes: 3,536 additions & 397 deletions package-lock.json

Large diffs are not rendered by default.

33 changes: 20 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
"dist-prod": "webpack --mode=production",
"full-dev": "npm run test && npm run build && npm run dist-dev",
"full-prod": "npm run test && npm run build && npm run dist-prod",
"distribute": "copy .\\playground\\index.html D:\\xampp\\htdocs\\games && copy .\\dist\\APGames.js D:\\xampp\\htdocs\\games",
"quick": "npm run build-ts && npm run dist-dev && npm run distribute",
"json2ts": "npx json2ts -i src/schemas/gamerecord.json -o src/schemas/gamerecord.d.ts "
},
"repository": {
Expand All @@ -31,19 +29,28 @@
"records"
],
"devDependencies": {
"@types/chai": "^4.2.22",
"@types/mocha": "^9.0.0",
"chai": "^4.3.4",
"json-schema-to-typescript": "^10.1.5",
"mocha": "^9.1.2",
"ts-loader": "^9.2.6",
"ts-node": "^10.4.0",
"@aws-sdk/types": "^3.433.0",
"@types/aws-lambda": "^8.10.125",
"@types/chai": "^4.3.9",
"@types/mocha": "^10.0.3",
"chai": "^4.3.10",
"json-schema-to-typescript": "^13.1.1",
"mocha": "^10.2.0",
"serverless-plugin-common-excludes": "^4.0.0",
"serverless-plugin-include-dependencies": "^5.1.0",
"ts-loader": "^9.5.0",
"ts-node": "^10.9.1",
"tslint": "^6.1.3",
"typescript": "^4.4.3",
"webpack": "^5.57.1",
"webpack-cli": "^4.8.0"
"typescript": "^5.2.2",
"webpack": "^5.89.0",
"webpack-cli": "^5.1.4"
},
"dependencies": {
"ajv": "^6.12.6"
"@aws-sdk/client-s3": "^3.441.0",
"ajv": "^8.12.0",
"ajv-formats": "^2.1.1",
"aws-lambda": "^1.0.7",
"ion-js": "^5.2.0",
"nanoid": "^5.0.2"
}
}
8 changes: 5 additions & 3 deletions src/raters/_base.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Ajv from "ajv";
import Ajv, {type ValidateFunction} from "ajv";
import addFormats from "ajv-formats";
import { APGameRecord } from "../schemas/gamerecord"
import schema from "../schemas/gamerecord.json";

Expand Down Expand Up @@ -31,7 +32,7 @@ export abstract class Rater {
protected failHard: boolean = false;
protected minRounds: number = 3;
protected respectUnrated: boolean = true;
protected validate: Ajv.ValidateFunction;
protected validate: ValidateFunction;

constructor(opts?: IRaterOptions) {
if (opts !== undefined) {
Expand All @@ -46,7 +47,8 @@ export abstract class Rater {
}
}

const ajv = new Ajv();
const ajv = new Ajv({allowUnionTypes: true});
addFormats(ajv);
this.validate = ajv.compile(schema);
}

Expand Down
6 changes: 5 additions & 1 deletion src/schemas/gamerecord.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* tslint:disable */
/* eslint-disable */
/**
* This file was automatically generated by json-schema-to-typescript.
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
Expand All @@ -23,6 +23,8 @@ export interface APGameRecord {
name: string;
/**
* Variants used in this game.
*
* @minItems 0
*/
variants?: string[];
};
Expand Down Expand Up @@ -65,6 +67,8 @@ export interface APGameRecord {
unrated?: boolean;
/**
* List of the players and their userids and final scores. They should be listed in seating order (first player, then second player, etc.). Additional properties are accepted, so feel free to include information specifically relevant to a particular game. Any additional properties should be provided consistently for any reports from that site for that game.
*
* @minItems 1
*/
players: [
{
Expand Down
2 changes: 1 addition & 1 deletion src/schemas/gamerecord.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "http://json-schema.org/schema#",
"id": "https://www.abstractplay.com/schemas/gamerecord/1-0-0.json#",
"$id": "https://www.abstractplay.com/schemas/gamerecord/1-0-0.json#",
"title": "AP Game Record",
"description": "Schema describing expected response of a game script to an 'archive' request. The structure is modelled after chess PGN files because many (even most) abstract strategy games can be represented with such notation. Each game will define its own move notation. We chose to go with a JSON schema over raw PGN because there are important games (such as Homeworlds) that don't work well with pure PGN. These reports are the reports of record. Game data is periodically purged from the main databases. Player rankings and ratings are calculated based on these game reports. This format is also being extended so it can be used by other game services. That way we could run a centralized records & ranking service that could work across game platforms.",
"type": "object",
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es2015",
"target": "es2021",
"esModuleInterop": true,
"sourceMap": true,
"declaration": true,
Expand Down
3 changes: 2 additions & 1 deletion tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"jsRules": {},
"rules": {
"max-line-length": false,
"array-type": false
"array-type": false,
"no-string-literal": false
},
"rulesDirectory": []
}

0 comments on commit e42214b

Please sign in to comment.