Skip to content

Conversation

blackrabbit99
Copy link
Contributor

add /api/v1/entries/:fqrn endpoint.
It allows to patch fully qualified resource names (SharedLibs and Applications).
Motivation for it is providing single resource to update common properties for general entities.
Use case is patching localisation manifest in single way for SharedLibs and Applications

Copy link
Contributor

@b1ff b1ff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to run auto-formatting on the changeset.

assetsManifestContent = response.data;

} catch (error) {
throw new AssetsManifestError(`"assetsDiscoveryUrl" ${assetsManifestUrl} is not available. Check the url via browser manually.`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like it hides original error. Can we propagate it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think in that case we should not distinguish an error. Any network error shows us we have to debug accessibility of asset

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that, but if we do not have original error in error that is thrown and do not have it in logs, it would be hard to debug

try {
return await assetsManifestContentValidator.validateAsync(assetsManifestContent);
} catch(error) {
throw new AssetsManifestError('"spaBundle" must be specified in the manifest file from provided "assetsDiscoveryUrl" if it was not specified manually');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd propagate original Joi error

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. Joi error will be more reliable in this case because validation object can be extended.

@blackrabbit99
Copy link
Contributor Author

Would be nice to run auto-formatting on the changeset.

I have added prettier for registry. It is running on pre-commit hook.
In next PR will integrate it with ilc

} else if (identifier.startsWith(this.resourceIdentifiers.APP)) {
const entityIdentifier = this.getEntityIdentifier(identifier, this.resourceIdentifiers.APP);
return this.getAppInstance(entityIdentifier);
} else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to have else condition here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Changed.

@@ -0,0 +1,3 @@
export class FqrnError extends Error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it is better to rename to FullyQualifiedResourceNameError ?

try {
results = await entryService.patch(params, { user: request.user });
} catch (error) {
if (error instanceof NotFoundFqrnError) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (error instanceof NotFoundFqrnError || error instanceof ValidationFqrnError) {
return response.status(error.code).send(error.message);
}

if (error instanceof Joi.ValidationError) {
return response.status(422).send(joiErrorToResponse(error));
}

if (error instanceof AssetsManifestError) {
return response.status(error.code).send(error.message);
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it make sence to optimize catching approach a bit later since all routes are supported single approach.
In ideal case all errors should be presented in single format that could be parsed in the same manner.

try {
results = await sharedLibEntry.patch(sharedLib, { user: req.user });
} catch (error) {
if (error instanceof NotFoundFqrnError) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need in else if conditions here

@blackrabbit99 blackrabbit99 merged commit cb083c9 into master Nov 8, 2022
@blackrabbit99 blackrabbit99 deleted the feature/add-entry-patch-endpoint branch November 8, 2022 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants