-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Decentralize the Input Validation Domain #532
Comments
Avoiding single points of failure in Polykey is quite critical. It always slows down our development whenever we need to test some changes in a feature branch but changes in one domain breaks another domain. |
Expanding the main users of You can see here the that handlers end up importing utilities. if we were to change one of the domains, let's say |
Would be cool if it was possible to auto-detect high-impact factor points in the code, and find places that have too much mutual recursion. |
@tegefaulkes this is a loose-end, might do well to tie this up as we continue development. |
I'd prefer to do it all at once. It's a simple change and better to have a clean commit for it. |
Note that all ID external parsers, encoders and decoders relating to Ids should probably all be inside However |
I've noticed that you're using the For example |
An older example is:
Which is in |
According to https://github.com/MatrixAI/MatrixAI-Graph/issues/44 the validation domain currently is a single point of failure because of:
The
src/validation
domain contains:The
index.ts
anderrors.ts
is fine, as they both contain the "generic" validation procedures. We can move the functions insideindex.ts
intoutils.ts
and then re-export it (unscoped) insideindex.ts
. That meansvalidate
, andvalidateSync
.The existing functions inside
utils.ts
are all theparseX
functions as per the list in https://github.com/MatrixAI/MatrixAI-Graph/issues/44All of these
parseX
functions should be moved into their respective domain utilities rather than being invalidation/utils.ts
. That's all of this:However these parse functions use the
validationErrors.ErrorParse
. That meansvalidation
domain can be imported by the other domains. This is actually already done bysrc/claims/utils.ts
. Notice it importsimport * as validationErrors from '../validation/errors';
and uses it for itsassertX
functions.This does mean that technically these domains aren't entirely self-contained since they at least depend on a
validationErrors.ErrorParse
exception. TheErrorParse
could later be factored out tojs-validation
if we want to to share this structure across projects, like injs-mdns
which also uses theparseX/generateX
structure in its DNS packets.Ok final issue is all the places in the code that uses
validationUtils.parseX
. All of this has to be changed. In order to fully decentralise, they should be importing their respectivedomainUtils.parseX
instead of relying onvalidationUtils.parseX
. We could "re-export" all of theseparseX
functions, but that defeats the point of decentralization. We need to just change our import paths for these usages. That shouldn't be too difficult, can do a find all in vscode.Tasks
parseX
insidesrc/validation/utils.ts
into their respective domains.domain/utils.ts
they should import thesrc/validation/errors.ts
asvalidationErrors
, seesrc/claims/utils.ts
to see how to do this.src/validation/utils.ts
should now be usingdomainUtils.parseX
instead avoiding a centralised import onvalidation
domain as a "many to many" nexus in our codebase.[ ] 4. We can move the- not going to do this, it's fine the way it issrc/validation/index.ts
functions intosrc/validation/utils.ts
and re-export it unscoped insidesrc/validation
, allowing one toimport { validate, validateSync } from '../validation';
.This allows us to in the future extract out the entire validation domain as
js-validation
library (although I think it should be called something else, just to avoid confusion with general input validation). This is not settled though, it may not be necessary.The text was updated successfully, but these errors were encountered: