Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,32 @@ interface ListState {
items: Cell<Item[]>;
}
const removeItem = handler({} as const satisfies JSONSchema, {
$schema: "https://json-schema.org/draft-07/schema#",
type: "object",
properties: {
items: {
type: "array",
items: {
type: "object",
properties: {
text: {
type: "string"
}
},
required: ["text"]
$ref: "#/definitions/Item"
},
asCell: true
},
index: {
type: "number"
}
},
required: ["items", "index"]
required: ["items", "index"],
definitions: {
Item: {
type: "object",
properties: {
text: {
type: "string"
}
},
required: ["text"]
}
}
} as const satisfies JSONSchema, (_, { items, index }) => {
const next = items.get().slice();
if (index >= 0 && index < next.length)
Expand All @@ -38,26 +44,32 @@ type ListStateWithIndex = ListState & {
index: number;
};
const removeItemAlias = handler({} as const satisfies JSONSchema, {
$schema: "https://json-schema.org/draft-07/schema#",
type: "object",
properties: {
items: {
type: "array",
items: {
type: "object",
properties: {
text: {
type: "string"
}
},
required: ["text"]
$ref: "#/definitions/Item"
},
asCell: true
},
index: {
type: "number"
}
},
required: ["items", "index"]
required: ["items", "index"],
definitions: {
Item: {
type: "object",
properties: {
text: {
type: "string"
}
},
required: ["text"]
}
}
} as const satisfies JSONSchema, (_, { items, index }) => {
const next = items.get().slice();
if (index >= 0 && index < next.length)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,117 +9,57 @@ interface TimedState {
history: Map<string, Date>;
}
const timedHandler = handler({
$schema: "https://json-schema.org/draft-07/schema#",
type: "object",
properties: {
timestamp: {
type: "string",
format: "date-time"
},
data: {
$ref: "#/definitions/Map"
}
},
required: ["timestamp", "data"],
definitions: {
Map: {
type: "object",
properties: {
clear: {
type: "object",
properties: {}
},
delete: {
type: "object",
properties: {}
},
forEach: {
type: "object",
properties: {}
},
get: {
type: "object",
properties: {}
},
has: {
type: "object",
properties: {}
},
set: {
type: "object",
properties: {}
},
size: {
type: "number"
},
entries: {
type: "object",
properties: {}
},
keys: {
type: "object",
properties: {}
},
values: {
type: "object",
properties: {}
}
},
required: ["clear", "delete", "forEach", "get", "has", "set", "size", "entries", "keys", "values"]
required: ["size"]
}
},
required: ["timestamp", "data"]
}
} as const satisfies JSONSchema, {
$schema: "https://json-schema.org/draft-07/schema#",
type: "object",
properties: {
lastUpdate: {
type: "string",
format: "date-time"
},
history: {
$ref: "#/definitions/Map"
}
},
required: ["lastUpdate", "history"],
definitions: {
Map: {
type: "object",
properties: {
clear: {
type: "object",
properties: {}
},
delete: {
type: "object",
properties: {}
},
forEach: {
type: "object",
properties: {}
},
get: {
type: "object",
properties: {}
},
has: {
type: "object",
properties: {}
},
set: {
type: "object",
properties: {}
},
size: {
type: "number"
},
entries: {
type: "object",
properties: {}
},
keys: {
type: "object",
properties: {}
},
values: {
type: "object",
properties: {}
}
},
required: ["clear", "delete", "forEach", "get", "has", "set", "size", "entries", "keys", "values"]
required: ["size"]
}
},
required: ["lastUpdate", "history"]
}
} as const satisfies JSONSchema, (event, state) => {
state.lastUpdate = event.timestamp;
event.data.forEach((value, key) => {
state.history.set(key, new Date());
});
});
export { timedHandler };
export { timedHandler };
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,13 @@ interface State {
taxRate: number;
}
export default recipe({
$schema: "https://json-schema.org/draft-07/schema#",
type: "object",
properties: {
items: {
type: "array",
items: {
type: "object",
properties: {
id: {
type: "number"
},
name: {
type: "string"
},
price: {
type: "number"
},
active: {
type: "boolean"
}
},
required: ["id", "name", "price", "active"]
$ref: "#/definitions/Item"
}
},
filter: {
Expand All @@ -46,7 +32,27 @@ export default recipe({
type: "number"
}
},
required: ["items", "filter", "discount", "taxRate"]
required: ["items", "filter", "discount", "taxRate"],
definitions: {
Item: {
type: "object",
properties: {
id: {
type: "number"
},
name: {
type: "string"
},
price: {
type: "number"
},
active: {
type: "boolean"
}
},
required: ["id", "name", "price", "active"]
}
}
} as const satisfies JSONSchema, (state) => {
return {
[UI]: (<div>
Expand Down Expand Up @@ -84,4 +90,3 @@ export default recipe({
</div>),
};
});

Loading