From 43e2862fcb498116ddbe6847d71b2dbc098510a5 Mon Sep 17 00:00:00 2001 From: Christian Stussak Date: Mon, 25 Mar 2024 15:17:40 +0100 Subject: [PATCH 1/4] Remove config file number again Each configuration file contains its own configuration key. Therefore, config keys will never be overwritten and the loading order doesn't matter. --- config/{00-model.yaml => model.yaml} | 0 ...-parameter-transforms.yaml => parameter-transforms.yaml} | 0 config/{10-simulation.yaml => simulation.yaml} | 0 src/ts/builtin-config.ts | 6 +++--- 4 files changed, 3 insertions(+), 3 deletions(-) rename config/{00-model.yaml => model.yaml} (100%) rename config/{20-parameter-transforms.yaml => parameter-transforms.yaml} (100%) rename config/{10-simulation.yaml => simulation.yaml} (100%) diff --git a/config/00-model.yaml b/config/model.yaml similarity index 100% rename from config/00-model.yaml rename to config/model.yaml diff --git a/config/20-parameter-transforms.yaml b/config/parameter-transforms.yaml similarity index 100% rename from config/20-parameter-transforms.yaml rename to config/parameter-transforms.yaml diff --git a/config/10-simulation.yaml b/config/simulation.yaml similarity index 100% rename from config/10-simulation.yaml rename to config/simulation.yaml diff --git a/src/ts/builtin-config.ts b/src/ts/builtin-config.ts index 058ba8a..ff2174c 100644 --- a/src/ts/builtin-config.ts +++ b/src/ts/builtin-config.ts @@ -2,9 +2,9 @@ import { DeepReadonly } from 'ts-essentials'; const CONFIG_BASE_URL = new URL('./config/', window.location.href); const CONFIG_FILENAMES = [ - '00-model.yaml', - '10-simulation.yaml', - '20-parameter-transforms.yaml', + 'model.yaml', + 'simulation.yaml', + 'parameter-transforms.yaml', ] as const; const CONFIG_URLS = CONFIG_FILENAMES.map( From d68231a4053b1780548229983e06ffaf43a4bc7b Mon Sep 17 00:00:00 2001 From: Christian Stussak Date: Wed, 20 Mar 2024 10:05:49 +0100 Subject: [PATCH 2/4] Make background image configurable via `general` config section --- {src/img => config/assets}/background.webp | Bin config/general.yaml | 2 ++ src/html/index.html | 4 +--- src/ts/builtin-config.ts | 1 + src/ts/config/config-schema-types.generated.ts | 3 +++ src/ts/config/suretype-config-schema.ts | 4 ++++ src/ts/index.ts | 9 +++++++++ src/yaml/config-schema.generated.yaml | 9 +++++++++ 8 files changed, 29 insertions(+), 3 deletions(-) rename {src/img => config/assets}/background.webp (100%) create mode 100644 config/general.yaml diff --git a/src/img/background.webp b/config/assets/background.webp similarity index 100% rename from src/img/background.webp rename to config/assets/background.webp diff --git a/config/general.yaml b/config/general.yaml new file mode 100644 index 0000000..258419b --- /dev/null +++ b/config/general.yaml @@ -0,0 +1,2 @@ +general: + backgroundImage: config/assets/background.webp diff --git a/src/html/index.html b/src/html/index.html index b9ab46a..52ba881 100644 --- a/src/html/index.html +++ b/src/html/index.html @@ -11,9 +11,7 @@
-
- -
+
diff --git a/src/ts/builtin-config.ts b/src/ts/builtin-config.ts index ff2174c..6a14c2e 100644 --- a/src/ts/builtin-config.ts +++ b/src/ts/builtin-config.ts @@ -2,6 +2,7 @@ import { DeepReadonly } from 'ts-essentials'; const CONFIG_BASE_URL = new URL('./config/', window.location.href); const CONFIG_FILENAMES = [ + 'general.yaml', 'model.yaml', 'simulation.yaml', 'parameter-transforms.yaml', diff --git a/src/ts/config/config-schema-types.generated.ts b/src/ts/config/config-schema-types.generated.ts index 17667ed..2dd7ab2 100644 --- a/src/ts/config/config-schema-types.generated.ts +++ b/src/ts/config/config-schema-types.generated.ts @@ -52,6 +52,9 @@ export interface InitialStocks { } export interface Config { + general: { + backgroundImage: string; + }; parameterTransforms: ParameterTransform[]; model: { initialParameters: InitialParameters; diff --git a/src/ts/config/suretype-config-schema.ts b/src/ts/config/suretype-config-schema.ts index 1b30543..bf99ce2 100644 --- a/src/ts/config/suretype-config-schema.ts +++ b/src/ts/config/suretype-config-schema.ts @@ -33,6 +33,10 @@ const ConfigSchema = suretype( { name: CONFIG_SCHEMA_NAME }, v .object({ + general: v + .object({ backgroundImage: v.string().required() }) + .additional(false) + .required(), parameterTransforms: ParameterTransformsSchema.required(), model: v .object({ diff --git a/src/ts/index.ts b/src/ts/index.ts index 6388c1f..94ff366 100644 --- a/src/ts/index.ts +++ b/src/ts/index.ts @@ -120,6 +120,15 @@ async function init(): Promise { game.runner.tick(); + const backgroundElement = document.createElement('img'); + backgroundElement.src = config.general.backgroundImage; + + const illustrationPanelElement = guardedQuerySelector( + HTMLElement, + '#illustration-panel', + ); + illustrationPanelElement.appendChild(backgroundElement); + const slotTracker = setupMarkerPanel(); slotTracker.slotActivate$.subscribe(({ slotId }) => { const slot = SLOT_DEFINITIONS.find((sd) => sd.id === slotId); diff --git a/src/yaml/config-schema.generated.yaml b/src/yaml/config-schema.generated.yaml index 797ab04..7193852 100644 --- a/src/yaml/config-schema.generated.yaml +++ b/src/yaml/config-schema.generated.yaml @@ -2,6 +2,14 @@ $schema: http://json-schema.org/draft-07/schema# title: Config type: object properties: + general: + type: object + properties: + backgroundImage: + type: string + required: + - backgroundImage + additionalProperties: false parameterTransforms: type: array items: @@ -29,6 +37,7 @@ properties: - maxStepSize additionalProperties: false required: + - general - parameterTransforms - model - simulation From 8ad4f93e0302a91e724ac898229e754967f24271 Mon Sep 17 00:00:00 2001 From: Christian Stussak Date: Mon, 25 Mar 2024 17:37:21 +0100 Subject: [PATCH 3/4] Add config schema for slot and card interaction --- config/interaction.yaml | 172 ++++++++++++++ src/ts/builtin-config.ts | 1 + .../config/config-schema-types.generated.ts | 80 ++++++- src/ts/config/suretype-config-schema.ts | 105 ++++++++- src/yaml/config-schema.generated.yaml | 210 ++++++++++++++++-- 5 files changed, 545 insertions(+), 23 deletions(-) create mode 100644 config/interaction.yaml diff --git a/config/interaction.yaml b/config/interaction.yaml new file mode 100644 index 0000000..b25b321 --- /dev/null +++ b/config/interaction.yaml @@ -0,0 +1,172 @@ +interaction: + slotActivationDelay: 1 + slotDeactivationDelay: 1 + slotGroups: + - id: technology + type: action-card + slots: + - { + id: technology-1, + x: 0, + y: 0, + angle: 0, + card: { x: 0, y: 0, angle: 0 }, + } + - { + id: technology-2, + x: 0, + y: 0, + angle: 0, + card: { x: 0, y: 0, angle: 0 }, + } + - { + id: technology-3, + x: 0, + y: 0, + angle: 0, + card: { x: 0, y: 0, angle: 0 }, + } + cards: + - id: technology-card-1 + url: technology-card-1.png + title: + en: 'T-Tech-en-1' + de: 'T-Tech-de-1' + description: + en: 'D-Tech-en-1' + de: 'D-Tech-de-1' + - id: technology-card-2 + url: technology-card-2.png + title: + en: 'T-Tech-en-2' + de: 'T-Tech-de-2' + description: + en: 'D-Tech-en-2' + de: 'D-Tech-de-2' + - id: technology-card-3 + url: technology-card-3.png + title: + en: 'T-Tech-en-3' + de: 'T-Tech-de-3' + description: + en: 'D-Tech-en-3' + de: 'D-Tech-de-3' + - id: technology-card-4 + url: technology-card-4.png + title: + en: 'T-Tech-en-4' + de: 'T-Tech-de-4' + description: + en: 'D-Tech-en-4' + de: 'D-Tech-de-4' + - id: policy + type: action-card + slots: + - { id: policy-1, x: 0, y: 0, angle: 0, card: { x: 0, y: 0, angle: 0 } } + - { id: policy-2, x: 0, y: 0, angle: 0, card: { x: 0, y: 0, angle: 0 } } + - { id: policy-3, x: 0, y: 0, angle: 0, card: { x: 0, y: 0, angle: 0 } } + cards: + - id: policy-card-1 + url: policy-card-1.png + title: + en: 'T-Pol-en-1' + de: 'T-Pol-de-1' + description: + en: 'D-Pol-en-1' + de: 'D-Pol-de-1' + - id: policy-card-2 + url: policy-card-2.png + title: + en: 'T-Pol-en-2' + de: 'T-Pol-de-2' + description: + en: 'D-Pol-en-2' + de: 'D-Pol-de-2' + - id: policy-card-3 + url: policy-card-3.png + title: + en: 'T-Pol-en-3' + de: 'T-Pol-de-3' + description: + en: 'D-Pol-en-3' + de: 'D-Pol-de-3' + - id: policy-card-4 + url: policy-card-4.png + title: + en: 'T-Pol-en-4' + de: 'T-Pol-de-4' + description: + en: 'D-Pol-en-4' + de: 'D-Pol-de-4' + - id: event + type: event-card + slots: + - { id: event, x: 0, y: 0, angle: 0, card: { x: 0, y: 0, angle: 0 } } + cards: + - id: event-card-1 + url: event-card-1.png + title: + en: 'T-Ev-en-1' + de: 'T-Ev-de-1' + description: + en: 'D-Ev-en-1' + de: 'D-Ev-de-1' + - id: event-card-2 + url: event-card-2.png + title: + en: 'T-Ev-en-2' + de: 'T-Ev-de-2' + description: + en: 'D-Ev-en-2' + de: 'D-Ev-de-2' + - id: event-card-3 + url: event-card-3.png + title: + en: 'T-Ev-en-3' + de: 'T-Ev-de-3' + description: + en: 'D-Ev-en-3' + de: 'D-Ev-de-3' + - id: event-card-4 + url: event-card-4.png + title: + en: 'T-Ev-en-4' + de: 'T-Ev-de-4' + description: + en: 'D-Ev-en-4' + de: 'D-Ev-de-4' + - id: reduce + type: basic + slots: + - { id: reduce-1, x: 0, y: 0, angle: 0 } + - { id: reduce-2, x: 0, y: 0, angle: 0 } + - { id: reduce-3, x: 0, y: 0, angle: 0 } + parameterTransformIds: [reduce, reduce, reduce] + - id: reuse + type: basic + slots: + - { id: reuse-1, x: 0, y: 0, angle: 0 } + - { id: reuse-2, x: 0, y: 0, angle: 0 } + - { id: reuse-3, x: 0, y: 0, angle: 0 } + parameterTransformIds: [reuse, reuse, reuse] + - id: repair + type: basic + slots: + - { id: repair-1, x: 0, y: 0, angle: 0 } + - { id: repair-2, x: 0, y: 0, angle: 0 } + - { id: repair-3, x: 0, y: 0, angle: 0 } + parameterTransformIds: [repair, repair, repair] + - id: refurbish + type: basic + slots: + - { id: refurbish-1, x: 0, y: 0, angle: 0 } + - { id: refurbish-2, x: 0, y: 0, angle: 0 } + - { id: refurbish-3, x: 0, y: 0, angle: 0 } + parameterTransformIds: [refurbish, refurbish, refurbish] + - id: recycle + type: basic + slots: + - { id: recycle-1, x: 0, y: 0, angle: 0 } + - { id: recycle-2, x: 0, y: 0, angle: 0 } + - { id: recycle-3, x: 0, y: 0, angle: 0 } + parameterTransformIds: [recycle, recycle, recycle] diff --git a/src/ts/builtin-config.ts b/src/ts/builtin-config.ts index 6a14c2e..9d91aec 100644 --- a/src/ts/builtin-config.ts +++ b/src/ts/builtin-config.ts @@ -6,6 +6,7 @@ const CONFIG_FILENAMES = [ 'model.yaml', 'simulation.yaml', 'parameter-transforms.yaml', + 'interaction.yaml', ] as const; const CONFIG_URLS = CONFIG_FILENAMES.map( diff --git a/src/ts/config/config-schema-types.generated.ts b/src/ts/config/config-schema-types.generated.ts index 2dd7ab2..421cab9 100644 --- a/src/ts/config/config-schema-types.generated.ts +++ b/src/ts/config/config-schema-types.generated.ts @@ -7,11 +7,6 @@ * - {@link https://github.com/grantila/typeconv} */ -export interface ParameterTransform { - id: string; - script: string; -} - export interface InitialParameters { abandonExcessRate: number; abandonRate: number; @@ -51,11 +46,78 @@ export interface InitialStocks { supplyOfRepairedPhones: number; } +export interface ParameterTransform { + id: string; + script: string; +} + +export interface BasicSlot { + id: string; + x: number; + y: number; + angle?: number; +} + +export interface BasicSlotGroup { + id: string; + type: 'basic'; + slots: BasicSlot[]; + parameterTransformIds: string[]; +} + +export interface SlotWithCard { + id: string; + x: number; + y: number; + angle?: number; + card: { + x: number; + y: number; + angle?: number; + }; +} + +export interface I18NString { + [key: string]: string; +} + +export interface ActionCard { + id: string; + url: string; + title: I18NString; + description: I18NString; +} + +export interface ActionCardSlotGroup { + id: string; + type: 'action-card'; + slots: SlotWithCard[]; + cards: ActionCard[]; +} + +export interface EventCard { + id: string; + url: string; + title: I18NString; + description: I18NString; +} + +export interface EventCardSlotGroup { + id: string; + type: 'event-card'; + slots: SlotWithCard[]; + cards: EventCard[]; +} + +export type SlotGroup = + | BasicSlotGroup + | ActionCardSlotGroup + | EventCardSlotGroup; + export interface Config { general: { backgroundImage: string; }; - parameterTransforms: ParameterTransform[]; model: { initialParameters: InitialParameters; initialStocks: InitialStocks; @@ -64,4 +126,10 @@ export interface Config { deltaPerSecond: number; maxStepSize: number; }; + parameterTransforms: ParameterTransform[]; + interaction: { + slotActivationDelay: number; + slotDeactivationDelay: number; + slotGroups: SlotGroup[]; + }; } diff --git a/src/ts/config/suretype-config-schema.ts b/src/ts/config/suretype-config-schema.ts index bf99ce2..b56430b 100644 --- a/src/ts/config/suretype-config-schema.ts +++ b/src/ts/config/suretype-config-schema.ts @@ -1,6 +1,11 @@ import { v, suretype } from 'suretype'; import { stockIds, parameterIds } from '../circular-economy-model'; +const I18NStringSchema = suretype( + { name: 'I18NString' }, + v.object({}).additional(v.string()), +); + const ParameterTransformSchema = suretype( { name: 'ParameterTransform' }, v @@ -27,6 +32,96 @@ const InitialStocksSchema = suretype( .additional(false), ); +const BasicSlotSchema = suretype( + { name: 'BasicSlot' }, + v + .object({ + id: v.string().required(), + x: v.number().required(), + y: v.number().required(), + angle: v.number().default(0), + }) + .additional(false), +); + +const SlotWithCardSchema = suretype( + { name: 'SlotWithCard' }, + v + .object({ + id: v.string().required(), + x: v.number().required(), + y: v.number().required(), + angle: v.number().default(0), + card: v + .object({ + x: v.number().required(), + y: v.number().required(), + angle: v.number().default(0), + }) + .additional(false) + .required(), + }) + .additional(false), +); + +const CardSchema = v + .object({ + id: v.string().required(), + url: v.string().required(), + title: I18NStringSchema.required(), + description: I18NStringSchema.required(), + }) + .additional(false); + +const ActionCardSchema = suretype({ name: 'ActionCard' }, CardSchema); + +const EventCardSchema = suretype({ name: 'EventCard' }, CardSchema); + +const BasicSlotGroupSchema = suretype( + { name: 'BasicSlotGroup' }, + v + .object({ + id: v.string().required(), + type: v.string().enum('basic').required(), + slots: v.array(BasicSlotSchema).required(), + parameterTransformIds: v.array(v.string()).required(), + }) + .additional(false), +); + +const ActionCardSlotGroupSchema = suretype( + { name: 'ActionCardSlotGroup' }, + v + .object({ + id: v.string().required(), + type: v.string().enum('action-card').required(), + slots: v.array(SlotWithCardSchema).required(), + cards: v.array(ActionCardSchema).required(), + }) + .additional(false), +); + +const EventCardSlotGroupSchema = suretype( + { name: 'EventCardSlotGroup' }, + v + .object({ + id: v.string().required(), + type: v.string().enum('event-card').required(), + slots: v.array(SlotWithCardSchema).required(), + cards: v.array(EventCardSchema).required(), + }) + .additional(false), +); + +const SlotGroupSchema = suretype( + { name: 'SlotGroup' }, + v.anyOf([ + BasicSlotGroupSchema, + ActionCardSlotGroupSchema, + EventCardSlotGroupSchema, + ]), +); + const CONFIG_SCHEMA_NAME = 'Config'; const ConfigSchema = suretype( @@ -37,7 +132,6 @@ const ConfigSchema = suretype( .object({ backgroundImage: v.string().required() }) .additional(false) .required(), - parameterTransforms: ParameterTransformsSchema.required(), model: v .object({ initialParameters: InitialParametersSchema.required(), @@ -52,6 +146,15 @@ const ConfigSchema = suretype( }) .additional(false) .required(), + parameterTransforms: ParameterTransformsSchema.required(), + interaction: v + .object({ + slotActivationDelay: v.number().required(), + slotDeactivationDelay: v.number().required(), + slotGroups: v.array(SlotGroupSchema).required(), + }) + .additional(false) + .required(), }) .additional(false) .required(), diff --git a/src/yaml/config-schema.generated.yaml b/src/yaml/config-schema.generated.yaml index 7193852..ae2194d 100644 --- a/src/yaml/config-schema.generated.yaml +++ b/src/yaml/config-schema.generated.yaml @@ -10,10 +10,6 @@ properties: required: - backgroundImage additionalProperties: false - parameterTransforms: - type: array - items: - $ref: '#/definitions/ParameterTransform' model: type: object properties: @@ -36,24 +32,34 @@ properties: - deltaPerSecond - maxStepSize additionalProperties: false + parameterTransforms: + type: array + items: + $ref: '#/definitions/ParameterTransform' + interaction: + type: object + properties: + slotActivationDelay: + type: number + slotDeactivationDelay: + type: number + slotGroups: + type: array + items: + $ref: '#/definitions/SlotGroup' + required: + - slotActivationDelay + - slotDeactivationDelay + - slotGroups + additionalProperties: false required: - general - - parameterTransforms - model - simulation + - parameterTransforms + - interaction additionalProperties: false definitions: - ParameterTransform: - type: object - properties: - id: - type: string - script: - type: string - required: - - id - - script - additionalProperties: false InitialParameters: type: object properties: @@ -163,3 +169,175 @@ definitions: - supplyOfRefurbishedPhones - supplyOfRepairedPhones additionalProperties: false + ParameterTransform: + type: object + properties: + id: + type: string + script: + type: string + required: + - id + - script + additionalProperties: false + BasicSlot: + type: object + properties: + id: + type: string + x: + type: number + 'y': + type: number + angle: + type: number + default: 0 + required: + - id + - x + - 'y' + additionalProperties: false + BasicSlotGroup: + type: object + properties: + id: + type: string + type: + type: string + enum: + - basic + slots: + type: array + items: + $ref: '#/definitions/BasicSlot' + parameterTransformIds: + type: array + items: + type: string + required: + - id + - type + - slots + - parameterTransformIds + additionalProperties: false + SlotWithCard: + type: object + properties: + id: + type: string + x: + type: number + 'y': + type: number + angle: + type: number + default: 0 + card: + type: object + properties: + x: + type: number + 'y': + type: number + angle: + type: number + default: 0 + required: + - x + - 'y' + additionalProperties: false + required: + - id + - x + - 'y' + - card + additionalProperties: false + I18NString: + type: object + additionalProperties: + type: string + ActionCard: + type: object + properties: + id: + type: string + url: + type: string + title: + $ref: '#/definitions/I18NString' + description: + $ref: '#/definitions/I18NString' + required: + - id + - url + - title + - description + additionalProperties: false + ActionCardSlotGroup: + type: object + properties: + id: + type: string + type: + type: string + enum: + - action-card + slots: + type: array + items: + $ref: '#/definitions/SlotWithCard' + cards: + type: array + items: + $ref: '#/definitions/ActionCard' + required: + - id + - type + - slots + - cards + additionalProperties: false + EventCard: + type: object + properties: + id: + type: string + url: + type: string + title: + $ref: '#/definitions/I18NString' + description: + $ref: '#/definitions/I18NString' + required: + - id + - url + - title + - description + additionalProperties: false + EventCardSlotGroup: + type: object + properties: + id: + type: string + type: + type: string + enum: + - event-card + slots: + type: array + items: + $ref: '#/definitions/SlotWithCard' + cards: + type: array + items: + $ref: '#/definitions/EventCard' + required: + - id + - type + - slots + - cards + additionalProperties: false + SlotGroup: + anyOf: + - $ref: '#/definitions/BasicSlotGroup' + - $ref: '#/definitions/ActionCardSlotGroup' + - $ref: '#/definitions/EventCardSlotGroup' From 563b08c006f88a8ece2c33ee9dd1a2aa0b0a0945 Mon Sep 17 00:00:00 2001 From: Christian Stussak Date: Mon, 25 Mar 2024 18:45:40 +0100 Subject: [PATCH 4/4] Add config schema for model event triggers --- config/triggers.yaml | 23 +++++++++++++++ src/ts/builtin-config.ts | 1 + .../config/config-schema-types.generated.ts | 11 +++++++ src/ts/config/suretype-config-schema.ts | 23 +++++++++++++++ src/yaml/config-schema.generated.yaml | 29 +++++++++++++++++++ 5 files changed, 87 insertions(+) create mode 100644 config/triggers.yaml diff --git a/config/triggers.yaml b/config/triggers.yaml new file mode 100644 index 0000000..83587ab --- /dev/null +++ b/config/triggers.yaml @@ -0,0 +1,23 @@ +triggers: + - id: test-1 + events: + - condition: + 'some condition based on the model elements (stocks, flows etc)' + url: 'url to the image' + - condition: + 'some condition based on the model elements (stocks, flows etc)' + url: 'url to the image' + - condition: + 'some condition based on the model elements (stocks, flows etc)' + url: 'url to the image' + - id: test-2 + events: + - condition: + 'some condition based on the model elements (stocks, flows etc)' + url: 'url to the image' + - condition: + 'some condition based on the model elements (stocks, flows etc)' + url: 'url to the image' + - condition: + 'some condition based on the model elements (stocks, flows etc)' + url: 'url to the image' diff --git a/src/ts/builtin-config.ts b/src/ts/builtin-config.ts index 9d91aec..22ad5a2 100644 --- a/src/ts/builtin-config.ts +++ b/src/ts/builtin-config.ts @@ -7,6 +7,7 @@ const CONFIG_FILENAMES = [ 'simulation.yaml', 'parameter-transforms.yaml', 'interaction.yaml', + 'triggers.yaml', ] as const; const CONFIG_URLS = CONFIG_FILENAMES.map( diff --git a/src/ts/config/config-schema-types.generated.ts b/src/ts/config/config-schema-types.generated.ts index 421cab9..563310c 100644 --- a/src/ts/config/config-schema-types.generated.ts +++ b/src/ts/config/config-schema-types.generated.ts @@ -114,6 +114,16 @@ export type SlotGroup = | ActionCardSlotGroup | EventCardSlotGroup; +export interface TriggerCondition { + condition: string; + url: string; +} + +export interface Trigger { + id: string; + events: TriggerCondition[]; +} + export interface Config { general: { backgroundImage: string; @@ -132,4 +142,5 @@ export interface Config { slotDeactivationDelay: number; slotGroups: SlotGroup[]; }; + triggers: Trigger[]; } diff --git a/src/ts/config/suretype-config-schema.ts b/src/ts/config/suretype-config-schema.ts index b56430b..7fb88df 100644 --- a/src/ts/config/suretype-config-schema.ts +++ b/src/ts/config/suretype-config-schema.ts @@ -122,6 +122,28 @@ const SlotGroupSchema = suretype( ]), ); +const TriggerCondition = suretype( + { name: 'TriggerCondition' }, + v + .object({ + condition: v.string().required(), + url: v.string().required(), + }) + .additional(false) + .required(), +); + +const TriggerSchema = suretype( + { name: 'Trigger' }, + v + .object({ + id: v.string().required(), + events: v.array(TriggerCondition).required(), + }) + .additional(false) + .required(), +); + const CONFIG_SCHEMA_NAME = 'Config'; const ConfigSchema = suretype( @@ -155,6 +177,7 @@ const ConfigSchema = suretype( }) .additional(false) .required(), + triggers: v.array(TriggerSchema).required(), }) .additional(false) .required(), diff --git a/src/yaml/config-schema.generated.yaml b/src/yaml/config-schema.generated.yaml index ae2194d..8af2531 100644 --- a/src/yaml/config-schema.generated.yaml +++ b/src/yaml/config-schema.generated.yaml @@ -52,12 +52,17 @@ properties: - slotDeactivationDelay - slotGroups additionalProperties: false + triggers: + type: array + items: + $ref: '#/definitions/Trigger' required: - general - model - simulation - parameterTransforms - interaction + - triggers additionalProperties: false definitions: InitialParameters: @@ -341,3 +346,27 @@ definitions: - $ref: '#/definitions/BasicSlotGroup' - $ref: '#/definitions/ActionCardSlotGroup' - $ref: '#/definitions/EventCardSlotGroup' + TriggerCondition: + type: object + properties: + condition: + type: string + url: + type: string + required: + - condition + - url + additionalProperties: false + Trigger: + type: object + properties: + id: + type: string + events: + type: array + items: + $ref: '#/definitions/TriggerCondition' + required: + - id + - events + additionalProperties: false