From e5c993d5dcdd5f402ab717724e3d4a9a7206b191 Mon Sep 17 00:00:00 2001 From: Lordmau5 Date: Thu, 14 Mar 2024 09:03:39 +0100 Subject: [PATCH] Add new currency options in the config Defaults to `$` and `en-US` for the currency symbol and country code respectively --- configschema.json | 20 ++- package-lock.json | 61 ++++++- package.json | 6 +- src/types/schemas/configschema.d.ts | 256 ++++++++++++++-------------- 4 files changed, 206 insertions(+), 137 deletions(-) diff --git a/configschema.json b/configschema.json index 6ece55c..8192850 100644 --- a/configschema.json +++ b/configschema.json @@ -94,6 +94,22 @@ "fallbackTwitchTitle": { "$comment": "Set the fallback Twitch title for this event; {{total}} and {{run}} can be used as placeholders (see source code).", "type": "string" + }, + "currency": { + "$comment": "Overrides for the currency symbol and country code used in various graphics", + "additionalProperties": false, + "properties": { + "symbol": { + "$comment": "The currency symbol (defaults to $)", + "type": "string", + "default": "$" + }, + "countryCode": { + "$comment": "The country code (defaults to en-US)", + "type": "string", + "default": "en-US" + } + } } }, "required": [ @@ -356,7 +372,7 @@ ] }, "groups": { - "type": "object", + "type": "object", "additionalProperties": false, "properties": { "gameCaptures": { @@ -745,4 +761,4 @@ "streamlabsCharity", "therungg" ] -} +} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index d880ffc..eed1733 100644 --- a/package-lock.json +++ b/package-lock.json @@ -60,6 +60,7 @@ "globby": "^12.2.0", "gsap": "^3.12.5", "html-webpack-plugin": "^5.6.0", + "json-schema-to-typescript": "^13.1.2", "mini-css-extract-plugin": "^2.7.7", "nodecg-cli": "^8.6.8", "npm-run-all": "^4.1.5", @@ -303,15 +304,21 @@ } }, "node_modules/@bcherny/json-schema-ref-parser": { - "version": "9.0.9", - "resolved": "https://registry.npmjs.org/@bcherny/json-schema-ref-parser/-/json-schema-ref-parser-9.0.9.tgz", - "integrity": "sha512-vmEmnJCfpkLdas++9OYg6riIezTYqTHpqUTODJzHLzs5UnXujbOJW9VwcVCnyo1mVRt32FRr23iXBx/sX8YbeQ==", + "version": "10.0.5-fork", + "resolved": "https://registry.npmjs.org/@bcherny/json-schema-ref-parser/-/json-schema-ref-parser-10.0.5-fork.tgz", + "integrity": "sha512-E/jKbPoca1tfUPj3iSbitDZTGnq6FUFjkH6L8U2oDwSuwK1WhnnVtCG7oFOTg/DDnyoXbQYUiUiGOibHqaGVnw==", "dev": true, "dependencies": { "@jsdevtools/ono": "^7.1.3", "@types/json-schema": "^7.0.6", "call-me-maybe": "^1.0.1", "js-yaml": "^4.1.0" + }, + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://github.com/sponsors/philsturgeon" } }, "node_modules/@colors/colors": { @@ -6002,12 +6009,12 @@ } }, "node_modules/json-schema-to-typescript": { - "version": "11.0.3", - "resolved": "https://registry.npmjs.org/json-schema-to-typescript/-/json-schema-to-typescript-11.0.3.tgz", - "integrity": "sha512-EaEE9Y4VZ8b9jW5zce5a9L3+p4C9AqgIRHbNVDJahfMnoKzcd4sDb98BLxLdQhJEuRAXyKLg4H66NKm80W8ilg==", + "version": "13.1.2", + "resolved": "https://registry.npmjs.org/json-schema-to-typescript/-/json-schema-to-typescript-13.1.2.tgz", + "integrity": "sha512-17G+mjx4nunvOpkPvcz7fdwUwYCEwyH8vR3Ym3rFiQ8uzAL3go+c1306Kk7iGRk8HuXBXqy+JJJmpYl0cvOllw==", "dev": true, "dependencies": { - "@bcherny/json-schema-ref-parser": "9.0.9", + "@bcherny/json-schema-ref-parser": "10.0.5-fork", "@types/json-schema": "^7.0.11", "@types/lodash": "^4.14.182", "@types/prettier": "^2.6.1", @@ -6799,6 +6806,18 @@ "node": ">=8" } }, + "node_modules/nodecg-cli/node_modules/@bcherny/json-schema-ref-parser": { + "version": "9.0.9", + "resolved": "https://registry.npmjs.org/@bcherny/json-schema-ref-parser/-/json-schema-ref-parser-9.0.9.tgz", + "integrity": "sha512-vmEmnJCfpkLdas++9OYg6riIezTYqTHpqUTODJzHLzs5UnXujbOJW9VwcVCnyo1mVRt32FRr23iXBx/sX8YbeQ==", + "dev": true, + "dependencies": { + "@jsdevtools/ono": "^7.1.3", + "@types/json-schema": "^7.0.6", + "call-me-maybe": "^1.0.1", + "js-yaml": "^4.1.0" + } + }, "node_modules/nodecg-cli/node_modules/chalk": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/chalk/-/chalk-3.0.0.tgz", @@ -6835,6 +6854,34 @@ "node": ">=6 <7 || >=8" } }, + "node_modules/nodecg-cli/node_modules/json-schema-to-typescript": { + "version": "11.0.3", + "resolved": "https://registry.npmjs.org/json-schema-to-typescript/-/json-schema-to-typescript-11.0.3.tgz", + "integrity": "sha512-EaEE9Y4VZ8b9jW5zce5a9L3+p4C9AqgIRHbNVDJahfMnoKzcd4sDb98BLxLdQhJEuRAXyKLg4H66NKm80W8ilg==", + "dev": true, + "dependencies": { + "@bcherny/json-schema-ref-parser": "9.0.9", + "@types/json-schema": "^7.0.11", + "@types/lodash": "^4.14.182", + "@types/prettier": "^2.6.1", + "cli-color": "^2.0.2", + "get-stdin": "^8.0.0", + "glob": "^7.1.6", + "glob-promise": "^4.2.2", + "is-glob": "^4.0.3", + "lodash": "^4.17.21", + "minimist": "^1.2.6", + "mkdirp": "^1.0.4", + "mz": "^2.7.0", + "prettier": "^2.6.2" + }, + "bin": { + "json2ts": "dist/src/cli.js" + }, + "engines": { + "node": ">=12.0.0" + } + }, "node_modules/nodecg-cli/node_modules/jsonfile": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", diff --git a/package.json b/package.json index e39f30c..568b5c3 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,8 @@ "watch": "run-p watch:*", "watch:browser": "webpack -w", "watch:extension": "tsc -b tsconfig.extension.json -w", - "postinstall": "cd shared && node postinstall.js" + "postinstall": "cd shared && node postinstall.js", + "configschema": "json2ts --input configschema.json --output src/types/schemas/configschema.d.ts" }, "dependencies": { "@esamarathon/mq-events": "^1.0.1", @@ -81,6 +82,7 @@ "globby": "^12.2.0", "gsap": "^3.12.5", "html-webpack-plugin": "^5.6.0", + "json-schema-to-typescript": "^13.1.2", "mini-css-extract-plugin": "^2.7.7", "nodecg-cli": "^8.6.8", "npm-run-all": "^4.1.5", @@ -381,4 +383,4 @@ } ] } -} +} \ No newline at end of file diff --git a/src/types/schemas/configschema.d.ts b/src/types/schemas/configschema.d.ts index 8c9f289..4d38d0b 100644 --- a/src/types/schemas/configschema.d.ts +++ b/src/types/schemas/configschema.d.ts @@ -6,132 +6,136 @@ */ export interface Configschema { - useTestData: boolean; - event: { - theme?: string; - shorts: string | [string] | [string, string]; - thisEvent: number; - online: boolean | ('partial' | 'full'); - fallbackTwitchTitle?: string; - }; - omnibar: { - miniCredits: { - header: string; - screeners?: string; - tech?: string; - }; - }; - streamdeck: { - enabled: boolean; - port: number; - key: string; - debug: boolean; - }; - rabbitmq: { - enabled: boolean; - protocol: string; - hostname: string; - username: string; - password: string; - vhost: string; - queuePrepend?: string; - }; - obs: { - enabled: boolean; - address: string; - password: string; - canvasResolution: { - width: number; - height: number; - }; - names: { - scenes: { - commercials: string; - gameLayout: string; - readerIntroduction: string; - intermission: string; - intermissionPlayer: string; - countdown: string; - }; - sources: { - gameSources: string | [string, ...string[]]; - cameraSources: string | [string, ...string[]]; - cameraSourceCrowd?: string | null; - twitchSources: string | [string] | [string, string]; - videoPlayer: string; - donationSound: string; - }; - groups: { - gameCaptures: string | [string, ...string[]]; - cameraCaptures: string | [string, ...string[]]; - }; - }; - }; - music: { - enabled: boolean; - address: string; - username: string; - password: string; - }; - x32: { - enabled: boolean; - ip: string; - localPort: number; - xr18: boolean; - }; - xkeys: { - enabled: boolean; - }; - tracker: { - enabled: boolean; - address: string; - username: string; - password: string; - prizesUrl: string; - commentaryBias: BidwarBias; - otherBidwarBias: BidwarBias; - donationTotalInTitle: boolean; - }; - tts: { - enabled: boolean; - voiceAPI: string; - key: string; - }; - flagcarrier: { - enabled: boolean; - allowedDevices?: string | [string, ...string[]] | null; - group: string; - availableButtons: { - id: string; - name: string; - }[]; - }; - offsite: { - enabled: boolean; - address: string; - key: string; - }; - server: { - enabled: boolean; - address: string; - key: string; - }; - discord: { - enabled: boolean; - token: string; - textChannelId: string; - }; - streamlabsCharity: { - enabled: boolean; - apiUrl: string; - }; - therungg: { - enabled: boolean; - }; + useTestData: boolean; + event: { + theme?: string; + shorts: string | [string] | [string, string]; + thisEvent: number; + online: boolean | ("partial" | "full"); + fallbackTwitchTitle?: string; + currency?: { + symbol?: string; + countryCode?: string; + }; + }; + omnibar: { + miniCredits: { + header: string; + screeners?: string; + tech?: string; + }; + }; + streamdeck: { + enabled: boolean; + port: number; + key: string; + debug: boolean; + }; + rabbitmq: { + enabled: boolean; + protocol: string; + hostname: string; + username: string; + password: string; + vhost: string; + queuePrepend?: string; + }; + obs: { + enabled: boolean; + address: string; + password: string; + canvasResolution: { + width: number; + height: number; + }; + names: { + scenes: { + commercials: string; + gameLayout: string; + readerIntroduction: string; + intermission: string; + intermissionPlayer: string; + countdown: string; + }; + sources: { + gameSources: string | [string, ...string[]]; + cameraSources: string | [string, ...string[]]; + cameraSourceCrowd?: string | null; + twitchSources: string | [string] | [string, string]; + videoPlayer: string; + donationSound: string; + }; + groups: { + gameCaptures: string | [string, ...string[]]; + cameraCaptures: string | [string, ...string[]]; + }; + }; + }; + music: { + enabled: boolean; + address: string; + username: string; + password: string; + }; + x32: { + enabled: boolean; + ip: string; + localPort: number; + xr18: boolean; + }; + xkeys: { + enabled: boolean; + }; + tracker: { + enabled: boolean; + address: string; + username: string; + password: string; + prizesUrl: string; + commentaryBias: BidwarBias; + otherBidwarBias: BidwarBias; + donationTotalInTitle: boolean; + }; + tts: { + enabled: boolean; + voiceAPI: string; + key: string; + }; + flagcarrier: { + enabled: boolean; + allowedDevices?: string | [string, ...string[]] | null; + group: string; + availableButtons: { + id: string; + name: string; + }[]; + }; + offsite: { + enabled: boolean; + address: string; + key: string; + }; + server: { + enabled: boolean; + address: string; + key: string; + }; + discord: { + enabled: boolean; + token: string; + textChannelId: string; + }; + streamlabsCharity: { + enabled: boolean; + apiUrl: string; + }; + therungg: { + enabled: boolean; + }; } export interface BidwarBias { - bidId: number; - option1Id: number; - option2Id: number; - optionTitle: string; + bidId: number; + option1Id: number; + option2Id: number; + optionTitle: string; }