New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

rest-client-sdk

Package Overview
Dependencies
Maintainers
4
Versions
109
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rest-client-sdk - npm Package Compare versions

Comparing version 5.0.0 to 6.0.0

7

CHANGELOG.md
# Changelog
## 6.0.0
### Changed
- [BREAKING] UnitOfWork is disabled by default, one must add a prop `unitOfWorkEnabled` with value true to the config object passed to the RestClientSdk's constructor in order to enable it
- TokenStorage's `generateToken` and `refreshToken` methods are now memoized in order to avoid bugs when making concurrent calls
## 5.0.0

@@ -4,0 +11,0 @@

3

dist/types/index.d.ts

@@ -18,2 +18,3 @@ import RestClientSdk from './RestClientSdk';

import type RestClientSdkInterface from './RestClientSdkInterface';
import type { Config } from './RestClientSdkInterface';
import type TokenStorageInterface from './TokenStorageInterface';

@@ -24,2 +25,2 @@ import type TokenGeneratorInterface from './TokenGenerator/TokenGeneratorInterface';

export { AbstractClient, AbstractTokenGenerator, ClientCredentialsGenerator, PasswordGenerator, ProvidedTokenGenerator, Serializer, TokenStorage, UnauthorizedError, BadRequestError, ConflictError, ForbiddenError, OauthError, InvalidGrantError, InvalidScopeError, HttpError, InternalServerError, ResourceNotFoundError, Mapping, ClassMetadata, Attribute, Relation, };
export type { SerializerInterface, Token, SdkMetadata, RestClientSdkInterface, TokenStorageInterface, TokenGeneratorInterface, AsyncStorageInterface, };
export type { SerializerInterface, Token, Config, SdkMetadata, RestClientSdkInterface, TokenStorageInterface, TokenGeneratorInterface, AsyncStorageInterface, };

@@ -13,2 +13,3 @@ import AbstractClient from './client/AbstractClient';

useDefaultParameters?: boolean;
unitOfWorkEnabled?: boolean;
};

@@ -15,0 +16,0 @@ export default interface RestClientSdkInterface<M extends SdkMetadata> {

@@ -8,3 +8,3 @@ import Mapping from './Mapping';

mapping: Mapping;
constructor(mapping: Mapping);
constructor(mapping: Mapping, enabled?: boolean);
registerClean(id: Id, entity: Record<string, unknown>): void;

@@ -11,0 +11,0 @@ getDirtyEntity(id: Id): Record<string, unknown>;

{
"name": "rest-client-sdk",
"version": "5.0.0",
"version": "6.0.0",
"description": "Rest Client SDK for API",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -121,2 +121,3 @@ # Mapado Rest Client JS SDK [![Build Status](https://travis-ci.org/mapado/rest-client-js-sdk.svg?branch=master)](https://travis-ci.org/mapado/rest-client-js-sdk)

useDefaultParameters: true,
unitOfWorkEnabled: true, // if key is missing, UnitOfWork will be disabled by default
}; // path and scheme are mandatory

@@ -135,2 +136,31 @@

#### UnitOfWork
Adding the key `unitOfWorkEnabled` to the `config` object passed to the `RestClientSdk` constructor will enable or disable the UnitOfWork
The UnitOfWork keeps track of the changes made to entity props so as to only send dirty fields when updating that entity
```js
const productRepo = sdk.getRepository('products');
let product = await productRepo.find(1);
/*
considering the json body of the response was
{
"category": "book",
"name": "Tom Sawyer"
}
*/
product = product.set('name', 'Huckleberry Finn');
productRepo.update(product);
/*
The PUT call produced will be made with the json body : { "name": "Huckleberry Finn" }
It will not include other unchanged props like "category" which could overwrite existing values
(if not fetched and initialized with a default null value for example)
*/
```
When dealing with large collections of objects, the UnitOfWork can add a considerable memory overhead. If you do not plan to do updates, it is advised to leave it disabled
### Make calls

@@ -137,0 +167,0 @@

@@ -28,3 +28,7 @@ import RestClientSdk from './RestClientSdk';

import type { SdkMetadata } from './RestClientSdk';
// eslint-disable-next-line import/no-duplicates
import type RestClientSdkInterface from './RestClientSdkInterface';
// eslint-disable-next-line import/no-duplicates
import type { Config } from './RestClientSdkInterface';
import type TokenStorageInterface from './TokenStorageInterface';

@@ -61,2 +65,3 @@ import type TokenGeneratorInterface from './TokenGenerator/TokenGeneratorInterface';

Token,
Config,
SdkMetadata,

@@ -63,0 +68,0 @@ RestClientSdkInterface,

@@ -57,3 +57,3 @@ import JsSerializer from './serializer/JsSerializer';

this.unitOfWork = new UnitOfWork(this.mapping);
this.unitOfWork = new UnitOfWork(this.mapping, this.config.unitOfWorkEnabled);

@@ -60,0 +60,0 @@ this.#repositoryList = {};

@@ -14,2 +14,3 @@ import AbstractClient from './client/AbstractClient';

useDefaultParameters?: boolean;
unitOfWorkEnabled?: boolean;
};

@@ -16,0 +17,0 @@

@@ -5,2 +5,3 @@ /* eslint-disable camelcase */

import AsyncStorageInterface from './AsyncStorageInterface';
import { memoizePromise } from './decorator';
import type TokenStorageInterface from './TokenStorageInterface';

@@ -30,2 +31,5 @@

this.accessTokenKey = accessTokenKey;
this.generateToken = memoizePromise(this.generateToken);
this.refreshToken = memoizePromise(this.refreshToken);
}

@@ -32,0 +36,0 @@

@@ -102,5 +102,8 @@ /* eslint-disable @typescript-eslint/no-explicit-any */

constructor(mapping: Mapping) {
#enabled: boolean;
constructor(mapping: Mapping, enabled = false) {
this.mapping = mapping;
this.#enabled = enabled;
this.#storage = {};

@@ -110,2 +113,5 @@ }

registerClean(id: Id, entity: Record<string, unknown>): void {
if (!this.#enabled) {
return;
}
if (isImmutable(entity)) {

@@ -112,0 +118,0 @@ this.#storage[id] = entity;

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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