Releases: astrohelm/metaforge
MetaForge V1.0.0
MetaForge V0.8.0
Update 2023-11-08
JSDOC
To have JSDOC comments in your type annotations you need to add $meta
field to your
schema; Also, your $meta
properties should start with @
;
Example
({
reciever: 'number',
money: 'number',
$meta: {
'@version': 'v1',
'@name': 'Pay check',
'@description': 'Cash settlement',
'@example': '<caption>Check example</caption>\n{ money: 100, reciever: 2 }',
},
});
MetaForge V0.7.0
Update 2023-11-08
Calculated fields
Calculated fields supposed to do preprocessing of your schema;
Warning: experimental. We do not support some types yet: Map, Set
Example
const schema = {
$id: 'user',
name: 'string',
phrase: (sample, schema, root) => 'Hello ' + schema.name + ' !',
};
const sample = { name: 'Alexander' };
new Schema(schema).calc(sample); // { ..., name: 'Alexander', phrase: 'Hello Alexander !'};
schema; // { $id: 'user', name: 'Alexander', phrase: 'Hello Alexander !'};
Writing calculated fields
Calculated fields is a function that receives two arguments:
- root: root object
{ input: Sample }
- parent: assigned target object
Warning: your return value will be assigned to samples
Additional
Method schema.calc
receives mode as second parameter; This method allow to specify
return value as:
- Schema.calc(sample, true); // Returns copy of sample with assigned values
- Schema.calc(sample); // Returns sample object with assigned values
MetaForge V0.6.0
Update 2023-11-06
- Typescript generation module
- Documentation fixes
MetaForge V0.5.0
Update 2023-11-05
- Readme enhancement
- JSDOC documentation
MetaForge V0.4.0
Update 2023-11-05
-
Support latest:21 node version
-
Removed parser (maybe temporary)
-
TypeScript .d.ts support
-
Schema field with multiple type variants now works only with special type
union
-
Modular mechanism (internal rework): How it works
const schema = new Schema(); schema.register((schema, options, plan) => {}); //? Register new module
By default registrated modules are:
- Metatest module (Adds tests for prototypes)
- Metatype module (Typescript parser)
- Handyman (Quality of life module)
But you also remove default modules:
Schema.modules.delete('metatest');
-
New shorthands for:
- enum example:
['winter', 'spring', 'summer, 'autumn']
- tuple example:
['string', 'number']
- object example:
{ a: string, b: number }
- string example:
'string'
- schema example:
'MyGlobalSchema'
- schema#2 example:
new Schema('string')
- enum example:
-
Removed preprocessor mechanism
-
Schemas now can be part of plan
-
Performance improvements (by removing unnecessary modules)
-
Lightweight inheritance
-
Removed type JSON (temporary)
-
Prototype chaining
-
Partial testing
-
New prototypes:
- Tuple
- Record
- Schema
- Union
MetaForge V0.3.0
Release 2023-10-16
- Schema child method, now you can update only schema or only options for new schemas
- Metadata fetcher, now you can gather all metadata by
schema.meta
- Fixed case when schema returns only methods without metadata, now it returns prototypes key with
all metadata - Preprocess & postprocess for objects properties mutations
- New prototype
enum
- Code cleanup & tests
MetaForge V0.2.0
MetaForge V0.1.0
Release 2023-10-16
- Stable release version
- Warnings before testing
- Repository created
- Namespaces, runtime schema checking, custom types
- Default struct types: Array, Set, Map, Object
- Default scalar types: String, Boolean, Number, BigInt
- Default exotic types: Any, Undefined, JSON
- Custom Errors