@dmitrymin/eventmapper-common
v2.6.102
Published
EventMapper common types and utilities
Downloads
114
Readme
EventMapper Common
Common types and utilities shared across EventMapper applications.
Publish
npm run relase # trigger automatic version change and push to github
npm publish
Installation
npm install eventmapper-common
Data schema, types, validation
GraphQL
- https://khalilstemmler.com/articles/graphql/graphql-schemas-vs-restful-dtos/
GraphQL -> Resolvers -> |Domain Boundary| -> Services -> Loaders -> Data Sources (Postgres/Redis/Elasticsearch)
- https://stackoverflow.com/questions/64178320/how-lazy-should-a-graphql-resolver-be
https://2ality.com/2020/06/validating-data-typescript.html#approaches-for-data-validation-in-typescript
OpenAPI - https://www.npmjs.com/package/@openapi-contrib/json-schema-to-openapi-schema
Schema
To provide a common entity interface shareable across applications, entities are defined using JSON Schema DSL. JSON schema is then used to define the validator.
- https://githubmemory.com/repo/json-schema-org/json-schema-spec/issues/1087
- https://github.com/ajv-validator/ajv-formats
Types / Interfaces
TypeScript types are derived from the JSON Schema DSL with the help of TypeBox
The typing can be augmented using the TypeBox modifiers. This produces:
- types with optional & readonly property identifiers
- types with all enumarated properties // Strict() https://github.com/sinclairzx81/typebox#Strict // const U = Type.Strict(T)
External vs. internal representation of data...
Validation
Validation is handled by AJV
https://www.npmjs.com/package/ajv/v/6.12.6 https://ajv.js.org/packages/ajv-formats.html https://github.com/ajv-validator/ajv-errors https://caoslab.psy.cmu.edu:32443/developers/jsexperimentslayout/-/tree/homepage_full/client/node_modules/babel-loader/node_modules/ajv https://opensourcelibs.com/lib/typebox
- testing - https://moshfeu.medium.com/test-json-schema-with-ajv-and-jest-c1d2984234c9
Parsing / serialization -
https://ajv.js.org/guide/getting-started.html#parsing-and-serializing-json
- author on reddit - https://www.reddit.com/r/typescript/comments/oetimi/json_schema_runtime_type_system_for_typescript/
https://levelup.gitconnected.com/typescript-validation-with-ajv-1b70a76dd678 https://code.tutsplus.com/tutorials/validating-data-with-json-schema-part-1--cms-25343 https://spin.atomicobject.com/2018/03/26/typescript-data-validation/
Resources
Project setup
- https://blog.logrocket.com/publishing-node-modules-typescript-es-modules/
- https://www.freecodecamp.org/news/how-to-make-a-beautiful-tiny-npm-package-and-publish-it-2881d4307f78/
- https://www.intricatecloud.io/2020/02/creating-a-simple-npm-library-to-use-in-and-out-of-the-browser/
Versioning
- https://itnext.io/how-to-automate-versioning-and-publication-of-an-npm-package-233e8757a526
- https://unicorn-utterances.com/posts/setup-standard-version/
TSLint
- https://khalilstemmler.com/blogs/typescript/eslint-for-typescript/
Alternatives
- https://github.com/release-it/release-it