diff --git a/src/classes/Pricelist.ts b/src/classes/Pricelist.ts index fb03d7d8b..8a4b0bd52 100644 --- a/src/classes/Pricelist.ts +++ b/src/classes/Pricelist.ts @@ -27,6 +27,7 @@ export interface EntryData { intent: 0 | 1 | 2; // 'buy', 'sell', 'bank' buy?: Currency | null; sell?: Currency | null; + limit?: { buy: Currency | null; sell: Currency | null }; promoted?: 0 | 1; group?: string | null; note?: { buy: string | null; sell: string | null }; @@ -53,6 +54,8 @@ export class Entry implements EntryData { sell: Currencies | null; + limit: { buy: Currencies | null; sell: Currencies | null }; + promoted: 0 | 1; group: string | null; diff --git a/src/lib/validator.ts b/src/lib/validator.ts index 33ac0fe37..84d27361e 100644 --- a/src/lib/validator.ts +++ b/src/lib/validator.ts @@ -6,6 +6,7 @@ const v = new Validator(); import * as pl from '../schemas/pricelist-json/export'; v.addSchema(pl.currenciesSchema); +v.addSchema(pl.limitSchema); v.addSchema(pl.pricelistSchema); v.addSchema(pl.addSchema); v.addSchema(pl.listingSchema); diff --git a/src/schemas/pricelist-json/export.ts b/src/schemas/pricelist-json/export.ts index 9c6ec0daa..2b60972aa 100644 --- a/src/schemas/pricelist-json/export.ts +++ b/src/schemas/pricelist-json/export.ts @@ -1,7 +1,8 @@ import { currenciesSchema } from './tf2-currencies'; +import { limitSchema } from './limit'; import { pricelistSchema } from './pricelist'; import { addSchema } from './pricelist-add'; import { listingSchema } from './listing-note'; import { pricesDataObject } from './pricesDataObject'; -export { currenciesSchema, pricelistSchema, addSchema, listingSchema, pricesDataObject }; +export { currenciesSchema, limitSchema, pricelistSchema, addSchema, listingSchema, pricesDataObject }; diff --git a/src/schemas/pricelist-json/limit.ts b/src/schemas/pricelist-json/limit.ts new file mode 100644 index 000000000..86cf2c75e --- /dev/null +++ b/src/schemas/pricelist-json/limit.ts @@ -0,0 +1,16 @@ +import jsonschema from 'jsonschema'; + +export const limitSchema: jsonschema.Schema = { + id: 'pricelist-limit', + type: 'object', + properties: { + buy: { + anyOf: [{ $ref: 'tf2-currencies' }, { type: null }] + }, + sell: { + anyOf: [{ $ref: 'tf2-currencies' }, { type: null }] + } + }, + additionalProperties: false, + required: ['buy', 'sell'] +}; diff --git a/src/schemas/pricelist-json/pricelist-add.ts b/src/schemas/pricelist-json/pricelist-add.ts index a066858c9..41c6a9ca3 100644 --- a/src/schemas/pricelist-json/pricelist-add.ts +++ b/src/schemas/pricelist-json/pricelist-add.ts @@ -41,6 +41,9 @@ export const addSchema: jsonschema.Schema = { // sell price $ref: 'tf2-currencies' }, + limit: { + $ref: 'pricelist-limit' + }, promoted: { // 0 = not promote, 1 = promote item (Sell only) type: 'integer', diff --git a/src/schemas/pricelist-json/pricelist.ts b/src/schemas/pricelist-json/pricelist.ts index 48e42ee2b..ca1e5fdf9 100644 --- a/src/schemas/pricelist-json/pricelist.ts +++ b/src/schemas/pricelist-json/pricelist.ts @@ -32,6 +32,9 @@ export const pricelistSchema: jsonschema.Schema = { sell: { $ref: 'tf2-currencies' }, + limit: { + $ref: 'pricelist-limit' + }, promoted: { type: 'integer', enum: [0, 1] diff --git a/src/schemas/pricelist-json/pricesDataObject.ts b/src/schemas/pricelist-json/pricesDataObject.ts index 071dded2e..bf97a7c3c 100644 --- a/src/schemas/pricelist-json/pricesDataObject.ts +++ b/src/schemas/pricelist-json/pricesDataObject.ts @@ -34,6 +34,9 @@ export const pricesDataObject: jsonschema.Schema = { sell: { $ref: 'tf2-currencies' }, + limit: { + $ref: 'pricelist-limit' + }, promoted: { type: 'number', enum: [0, 1]