@luvio/command-aura-network
Advanced tools
Comparing version 5.21.1-alpha.0 to 5.23.0
import { NetworkCommand } from '@luvio/command-network/v1'; | ||
import { type Result } from '@luvio/utils'; | ||
import type { NamedAuraNetworkService } from '@luvio/service-aura-network/v1'; | ||
import type { AuraRawResponseBody } from 'aura'; | ||
/** | ||
@@ -18,3 +19,5 @@ * An implementation of NetworkCommand that uses Aura as the transport mechanism | ||
}; | ||
protected coerceAuraErrors(auraErrors: any[]): Error; | ||
protected convertAuraResponseToData<Data = unknown>(responsePromise: Promise<AuraRawResponseBody<any>>, coerceError: (errors: any[]) => Error): Promise<Result<Data, Error>>; | ||
fetch(): PromiseLike<Result<Data, Error>>; | ||
} |
@@ -8,21 +8,4 @@ /** | ||
import { NetworkCommand } from '@luvio/command-network/v1'; | ||
import { ok, err, toError } from '@luvio/utils'; | ||
import { toError, ok, err } from '@luvio/utils'; | ||
function convertAuraResponseToData(responsePromise) { | ||
return responsePromise | ||
.then((response) => { | ||
return ok(response.getReturnValue()); | ||
}) | ||
.catch((error) => { | ||
if (!error || !error.getError) { | ||
return err(toError('Failed to get error from response')); | ||
} | ||
const actionErrors = error.getError(); | ||
if (actionErrors.length > 0) { | ||
return err(toError(actionErrors[0])); | ||
} | ||
return err(toError('Error fetching component')); | ||
}); | ||
} | ||
/** | ||
@@ -42,4 +25,23 @@ * An implementation of NetworkCommand that uses Aura as the transport mechanism | ||
} | ||
coerceAuraErrors(auraErrors) { | ||
return toError(auraErrors[0]); // Default Implmentation stringifies the response | ||
} | ||
convertAuraResponseToData(responsePromise, coerceError) { | ||
return responsePromise | ||
.then((response) => { | ||
return ok(response.getReturnValue()); | ||
}) | ||
.catch((error) => { | ||
if (!error || !error.getError) { | ||
return err(toError('Failed to get error from response')); | ||
} | ||
const actionErrors = error.getError(); | ||
if (actionErrors.length > 0) { | ||
return err(coerceError(actionErrors)); | ||
} | ||
return err(toError('Error fetching component')); | ||
}); | ||
} | ||
fetch() { | ||
return convertAuraResponseToData(this.services.auraNetwork(this.endpoint, this.auraParams, this.actionConfig)); | ||
return this.convertAuraResponseToData(this.services.auraNetwork(this.endpoint, this.auraParams, this.actionConfig), this.coerceAuraErrors); | ||
} | ||
@@ -46,0 +48,0 @@ } |
import { NetworkCommand } from '@luvio/command-network/v1'; | ||
import { type Result } from '@luvio/utils'; | ||
import type { NamedAuraNetworkService } from '@luvio/service-aura-network/v1'; | ||
import type { AuraRawResponseBody } from 'aura'; | ||
/** | ||
@@ -18,3 +19,5 @@ * An implementation of NetworkCommand that uses Aura as the transport mechanism | ||
}; | ||
protected coerceAuraErrors(auraErrors: any[]): Error; | ||
protected convertAuraResponseToData<Data = unknown>(responsePromise: Promise<AuraRawResponseBody<any>>, coerceError: (errors: any[]) => Error): Promise<Result<Data, Error>>; | ||
fetch(): PromiseLike<Result<Data, Error>>; | ||
} |
{ | ||
"name": "@luvio/command-aura-network", | ||
"version": "5.21.1-alpha.0", | ||
"version": "5.23.0", | ||
"private": false, | ||
@@ -33,5 +33,5 @@ "description": "Luvio Aura Network Command", | ||
"dependencies": { | ||
"@luvio/command-base": "5.21.1-alpha.0", | ||
"@luvio/command-network": "5.21.1-alpha.0", | ||
"@luvio/utils": "5.21.1-alpha.0" | ||
"@luvio/command-base": "5.23.0", | ||
"@luvio/command-network": "5.23.0", | ||
"@luvio/utils": "5.23.0" | ||
}, | ||
@@ -38,0 +38,0 @@ "volta": { |
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
18278
115
1
13
+ Added@luvio/command-base@5.23.0(transitive)
+ Added@luvio/command-network@5.23.0(transitive)
+ Added@luvio/utils@5.23.0(transitive)
- Removed@luvio/command-base@5.21.1-alpha.0(transitive)
- Removed@luvio/command-network@5.21.1-alpha.0(transitive)
- Removed@luvio/utils@5.21.1-alpha.0(transitive)
Updated@luvio/command-base@5.23.0
Updated@luvio/utils@5.23.0