Finalized field configuration for now, fixed a bug in resolvers, added readme stub for data package

This commit is contained in:
2026-04-11 21:45:42 +02:00
parent ae40c680de
commit 25dc8b8d0f
4 changed files with 25 additions and 5 deletions

View File

@@ -53,12 +53,12 @@ export class Field_Configuration {
export class Schema {
constructor(field_schema) {
Object.assign(this, { field_schema });
constructor(field_schema, name=undefined) {
Object.assign(this, { field_schema, name });
}
load(value={}, target=undefined) {
const { field_schema } = this;
const { field_schema, name } = this;
for (const [value_name, value_value] of Object.entries(value)) {
if (!field_schema[value_name]) {
@@ -69,8 +69,10 @@ export class Schema {
}
const result = {};
const this_schema = name ? `schema "${name}"` : 'untitled schema';
for (const [field_name, field_config] of Object.entries(field_schema)) {
const sub_target = { schema: this, field_name, field_config, parent_target: target };
const sub_target = { schema: this, name: field_name, config: field_config, parent_target: target, info: `Field "${field_name}" of ${this_schema}` };
result[field_name] = field_config.load(value[field_name], sub_target);
}