Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@luvio/utils

Package Overview
Dependencies
Maintainers
0
Versions
70
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@luvio/utils - npm Package Compare versions

Comparing version 5.21.1-alpha.0 to 5.23.0

dist/types/__tests__/error-handling.spec.d.ts

1

dist/types/index.d.ts

@@ -15,1 +15,2 @@ export * from './bfs';

export { satisfies, stringIsVersion, Version } from './version';
export * from './error-handling';

@@ -524,3 +524,81 @@ /**

export { isArray as ArrayIsArray, indexOf as ArrayPrototypeIndexOf, push as ArrayPrototypePush, slice as ArrayPrototypeSlice, ConsoleLogger, DataIncompleteError, DataNotFoundError, DefaultFileParserLogger, Err, stringify as JSONStringify, LogLevelMap, create as ObjectCreate, freeze as ObjectFreeze, keys as ObjectKeys, hasOwnProperty as ObjectPrototypeHasOwnProperty, Ok, addAllToSet, bfs, capitalize, deepEquals, err, includes, isCacheHitOrError, isCacheMiss, isDataIncompleteError, isDataNotFoundError, isPromiseLike, isSubscribable, loggerService, ok, racesync, rejectedPromiseLike, resolvedPromiseLike, satisfies, setDifference, setOverlaps, stableJSONStringify, stringIsVersion, toCamelCase, toError, toPascalCase, toScreamingSnakeCase, toTypeScriptSafeIdentifier, withResolvers };
var HttpStatusCode;
(function (HttpStatusCode) {
HttpStatusCode[HttpStatusCode["Ok"] = 200] = "Ok";
HttpStatusCode[HttpStatusCode["Created"] = 201] = "Created";
HttpStatusCode[HttpStatusCode["NoContent"] = 204] = "NoContent";
HttpStatusCode[HttpStatusCode["NotModified"] = 304] = "NotModified";
HttpStatusCode[HttpStatusCode["BadRequest"] = 400] = "BadRequest";
HttpStatusCode[HttpStatusCode["Unauthorized"] = 401] = "Unauthorized";
HttpStatusCode[HttpStatusCode["Forbidden"] = 403] = "Forbidden";
HttpStatusCode[HttpStatusCode["NotFound"] = 404] = "NotFound";
HttpStatusCode[HttpStatusCode["ServerError"] = 500] = "ServerError";
HttpStatusCode[HttpStatusCode["GatewayTimeout"] = 504] = "GatewayTimeout";
})(HttpStatusCode || (HttpStatusCode = {}));
// Logic from https://github.com/salesforce-experience-platform-emu/lds-lightning-platform/blob/main/packages/lds-network-aura/src/middlewares/utils.ts#L197
function getFetchResponseFromAuraError(err) {
// Handle ConnectInJava exception shapes
if (err.data !== undefined && err.data.statusCode !== undefined) {
let data = {};
data = err.data;
if (err.id !== undefined) {
data.id = err.id;
}
return new FetchResponse(data.statusCode, data);
}
// Handle all the other kind of errors
return new FetchResponse(HttpStatusCode.ServerError, {
error: err.message,
});
}
// Backwards-compatible fetch error coerce
// Adapted from https://github.com/salesforce-experience-platform-emu/luvio/blob/main/packages/@luvio/network-adapter-fetch/src/fetchNetworkAdapter.ts#L67
async function coerceResponseToFetchResponse(response) {
const { status } = response;
// coerce headers
const responseHeaders = {};
response.headers.forEach((value, key) => {
responseHeaders[key] = value;
});
// parse body
let responseBody = null;
if (status !== 204) {
const contentType = responseHeaders['content-type'];
responseBody =
contentType && contentType.startsWith('application/json')
? await response.json()
: await response.text();
}
return new FetchResponse(status, responseBody, responseHeaders);
}
function getStatusText(status) {
switch (status) {
case HttpStatusCode.Ok:
return 'OK';
case HttpStatusCode.Created:
return 'Created';
case HttpStatusCode.NotModified:
return 'Not Modified';
case HttpStatusCode.BadRequest:
return 'Bad Request';
case HttpStatusCode.NotFound:
return 'Not Found';
case HttpStatusCode.ServerError:
return 'Server Error';
default:
return `Unexpected HTTP Status Code: ${status}`;
}
}
class FetchResponse extends Error {
constructor(status, body, headers) {
super();
this.status = status;
this.body = body;
this.headers = headers || {};
this.ok = status >= 200 && this.status <= 299;
this.statusText = getStatusText(status);
}
}
export { isArray as ArrayIsArray, indexOf as ArrayPrototypeIndexOf, push as ArrayPrototypePush, slice as ArrayPrototypeSlice, ConsoleLogger, DataIncompleteError, DataNotFoundError, DefaultFileParserLogger, Err, FetchResponse, HttpStatusCode, stringify as JSONStringify, LogLevelMap, create as ObjectCreate, freeze as ObjectFreeze, keys as ObjectKeys, hasOwnProperty as ObjectPrototypeHasOwnProperty, Ok, addAllToSet, bfs, capitalize, coerceResponseToFetchResponse, deepEquals, err, getFetchResponseFromAuraError, includes, isCacheHitOrError, isCacheMiss, isDataIncompleteError, isDataNotFoundError, isPromiseLike, isSubscribable, loggerService, ok, racesync, rejectedPromiseLike, resolvedPromiseLike, satisfies, setDifference, setOverlaps, stableJSONStringify, stringIsVersion, toCamelCase, toError, toPascalCase, toScreamingSnakeCase, toTypeScriptSafeIdentifier, withResolvers };
//# sourceMappingURL=utils.js.map

2

package.json
{
"name": "@luvio/utils",
"version": "5.21.1-alpha.0",
"version": "5.23.0",
"description": "Luvio utils",

@@ -5,0 +5,0 @@ "repository": {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc