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

@superfaceai/one-sdk

Package Overview
Dependencies
Maintainers
3
Versions
135
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@superfaceai/one-sdk - npm Package Compare versions

Comparing version 0.0.30 to 0.0.31

7

CHANGELOG.md

@@ -10,2 +10,6 @@ # Changelog

## [0.0.31] - 2021-08-25
### Added
- Superjson mutate set methods for profile, profileProvider and provider
## [0.0.30] - 2021-08-24

@@ -214,3 +218,4 @@ ### Added

[Unreleased]: https://github.com/superfaceai/one-sdk-js/compare/v0.0.30...HEAD
[Unreleased]: https://github.com/superfaceai/one-sdk-js/compare/v0.0.31...HEAD
[0.0.31]: https://github.com/superfaceai/one-sdk-js/compare/v0.0.30...v0.0.31
[0.0.30]: https://github.com/superfaceai/one-sdk-js/compare/v0.0.29...v0.0.30

@@ -217,0 +222,0 @@ [0.0.29]: https://github.com/superfaceai/one-sdk-js/compare/v0.0.29-beta.7...v0.0.29

@@ -8,4 +8,8 @@ import { Result } from '../../lib';

export declare function mergeProfile(document: SuperJsonDocument, profileName: string, payload: ProfileEntry): boolean;
/** Sets profile of the document to payload or deletes it. */
export declare function setProfile(document: SuperJsonDocument, profileName: string, payload: ProfileEntry | undefined): boolean;
/** Merges profile provider into the document or creates the profile and providers object if it doesn't exist. */
export declare function mergeProfileProvider(document: SuperJsonDocument, profileName: string, providerName: string, payload: ProfileProviderEntry): boolean;
/** Sets profile provider of the document to payload or deletes it. */
export declare function setProfileProvider(document: SuperJsonDocument, profileName: string, providerName: string, payload: ProfileProviderEntry | undefined): boolean;
export declare function swapProfileProviderVariant(document: SuperJsonDocument, profileName: string, providerName: string, variant: {

@@ -21,2 +25,4 @@ kind: 'local';

export declare function mergeProvider(document: SuperJsonDocument, providerName: string, payload: ProviderEntry): boolean;
/** Sets provider of the document to payload or deletes it. */
export declare function setProvider(document: SuperJsonDocument, providerName: string, payload: ProviderEntry | undefined): boolean;
export declare function swapProviderVariant(document: SuperJsonDocument, providerName: string, variant: {

@@ -23,0 +29,0 @@ kind: 'local';

@@ -46,3 +46,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.setPriority = exports.mergeSecurity = exports.swapProviderVariant = exports.mergeProvider = exports.swapProfileProviderVariant = exports.mergeProfileProvider = exports.mergeProfile = exports.mergeProfileDefaults = void 0;
exports.setPriority = exports.mergeSecurity = exports.swapProviderVariant = exports.setProvider = exports.mergeProvider = exports.swapProfileProviderVariant = exports.setProfileProvider = exports.mergeProfileProvider = exports.setProfile = exports.mergeProfile = exports.mergeProfileDefaults = void 0;
var lib_1 = require("../../lib");

@@ -188,2 +188,21 @@ var errors_1 = require("../errors");

}
/** Sets profile of the document to payload or deletes it. */
function setProfile(document, profileName, payload) {
var changed = false;
// delete any existing profile
if (document.profiles !== undefined && profileName in document.profiles) {
changed = true;
delete document.profiles[profileName];
if (Object.keys(document.profiles).length === 0) {
delete document.profiles;
}
}
// if payload is undefined we already deleted it (or it wasn't present)
if (payload !== undefined) {
var mergeChanged = mergeProfile(document, profileName, payload);
changed = changed || mergeChanged;
}
return changed;
}
exports.setProfile = setProfile;
/**

@@ -300,2 +319,39 @@ * Ensure that profile exists (defaults to version '0.0.0') and that its providers key is defined (defaults to empty record).

exports.mergeProfileProvider = mergeProfileProvider;
/** Sets profile provider of the document to payload or deletes it. */
function setProfileProvider(document, profileName, providerName, payload) {
var changed = false;
// delete any existing profile provider
if (document.profiles !== undefined && profileName in document.profiles) {
var profile = document.profiles[profileName];
if (typeof profile !== 'string' &&
profile.providers !== undefined &&
providerName in profile.providers) {
changed = true;
delete profile.providers[providerName];
// remove from priority, but only if we are actually deleting
// otherwise preserve the priority order
if (payload === undefined) {
if (profile.priority !== undefined) {
var index = profile.priority.indexOf(providerName);
if (index >= 0) {
profile.priority.splice(index, 1);
}
if (profile.priority.length === 0) {
delete profile.priority;
}
}
}
if (Object.keys(profile.providers).length === 0) {
delete profile.providers;
}
}
}
// if payload is undefined we already deleted it (or it wasn't present)
if (payload !== undefined) {
var mergeChanged = mergeProfileProvider(document, profileName, providerName, payload);
changed = changed || mergeChanged;
}
return changed;
}
exports.setProfileProvider = setProfileProvider;
function swapProfileProviderVariant(document, profileName, providerName, variant) {

@@ -396,6 +452,11 @@ var _a = __read(ensureProfileWithProviders(document, profileName), 2), _ = _a[0], targetProfile = _a[1];

else {
document.providers[providerName] = {
file: (_b = payload.file) !== null && _b !== void 0 ? _b : targetProvider.file,
security: mergeSecurity((_c = targetProvider.security) !== null && _c !== void 0 ? _c : [], (_d = payload.security) !== null && _d !== void 0 ? _d : []),
};
var provider = {};
if (payload.file !== undefined || targetProvider.file !== undefined) {
provider.file = (_b = payload.file) !== null && _b !== void 0 ? _b : targetProvider.file;
}
if (targetProvider.security !== undefined ||
payload.security !== undefined) {
provider.security = mergeSecurity((_c = targetProvider.security) !== null && _c !== void 0 ? _c : [], (_d = payload.security) !== null && _d !== void 0 ? _d : []);
}
document.providers[providerName] = provider;
}

@@ -405,2 +466,21 @@ return true;

exports.mergeProvider = mergeProvider;
/** Sets provider of the document to payload or deletes it. */
function setProvider(document, providerName, payload) {
var changed = false;
// delete any existing provider
if (document.providers !== undefined && providerName in document.providers) {
changed = true;
delete document.providers[providerName];
if (Object.keys(document.providers).length === 0) {
delete document.providers;
}
}
// if payload is undefined we already deleted it (or it wasn't present)
if (payload !== undefined) {
var mergeChanged = mergeProvider(document, providerName, payload);
changed = changed || mergeChanged;
}
return changed;
}
exports.setProvider = setProvider;
function swapProviderVariant(document, providerName, variant) {

@@ -407,0 +487,0 @@ if (document.providers === undefined) {

@@ -40,2 +40,8 @@ import { Result } from '../../lib';

/**
* Sets (completely overwrites) a profile in the document.
*
* `payload === undefined` deletes the profile.
*/
setProfile(profileName: string, payload: ProfileEntry | undefined): boolean;
/**
* Merge profile provider into the document.

@@ -47,2 +53,8 @@ *

/**
* Sets (completely overwrites) a profile provider in the document.
*
* `payload === undefined` deletes the entry.
*/
setProfileProvider(profileName: string, providerName: string, payload: ProfileProviderEntry | undefined): boolean;
/**
* Swaps profile provider variant.

@@ -64,2 +76,8 @@ */

mergeProvider(providerName: string, payload: ProviderEntry): boolean;
/**
* Sets (completely overwrites) a provider in the document.
*
* `payload === undefined` deletes the provider.
*/
setProvider(providerName: string, payload: ProviderEntry | undefined): boolean;
swapProviderVariant(providerName: string, variant: {

@@ -66,0 +84,0 @@ kind: 'local';

72

dist/internal/superjson/superjson.js

@@ -223,7 +223,7 @@ "use strict";

SuperJson.prototype.mergeProfileDefaults = function (profileName, payload) {
var result = mutate_1.mergeProfileDefaults(this.document, profileName, payload);
if (result) {
var changed = mutate_1.mergeProfileDefaults(this.document, profileName, payload);
if (changed) {
this.normalizedCache = undefined;
}
return result;
return changed;
};

@@ -236,9 +236,21 @@ /**

SuperJson.prototype.mergeProfile = function (profileName, payload) {
var result = mutate_1.mergeProfile(this.document, profileName, payload);
if (result) {
var changed = mutate_1.mergeProfile(this.document, profileName, payload);
if (changed) {
this.normalizedCache = undefined;
}
return result;
return changed;
};
/**
* Sets (completely overwrites) a profile in the document.
*
* `payload === undefined` deletes the profile.
*/
SuperJson.prototype.setProfile = function (profileName, payload) {
var changed = mutate_1.setProfile(this.document, profileName, payload);
if (changed) {
this.normalizedCache = undefined;
}
return changed;
};
/**
* Merge profile provider into the document.

@@ -249,17 +261,29 @@ *

SuperJson.prototype.mergeProfileProvider = function (profileName, providerName, payload) {
var result = mutate_1.mergeProfileProvider(this.document, profileName, providerName, payload);
if (result) {
var changed = mutate_1.mergeProfileProvider(this.document, profileName, providerName, payload);
if (changed) {
this.normalizedCache = undefined;
}
return result;
return changed;
};
/**
* Sets (completely overwrites) a profile provider in the document.
*
* `payload === undefined` deletes the entry.
*/
SuperJson.prototype.setProfileProvider = function (profileName, providerName, payload) {
var changed = mutate_1.setProfileProvider(this.document, profileName, providerName, payload);
if (changed) {
this.normalizedCache = undefined;
}
return changed;
};
/**
* Swaps profile provider variant.
*/
SuperJson.prototype.swapProfileProviderVariant = function (profileName, providerName, variant) {
var result = mutate_1.swapProfileProviderVariant(this.document, profileName, providerName, variant);
if (result) {
var changed = mutate_1.swapProfileProviderVariant(this.document, profileName, providerName, variant);
if (changed) {
this.normalizedCache = undefined;
}
return result;
return changed;
};

@@ -272,14 +296,26 @@ /**

SuperJson.prototype.mergeProvider = function (providerName, payload) {
var result = mutate_1.mergeProvider(this.document, providerName, payload);
if (result) {
var changed = mutate_1.mergeProvider(this.document, providerName, payload);
if (changed) {
this.normalizedCache = undefined;
}
return result;
return changed;
};
/**
* Sets (completely overwrites) a provider in the document.
*
* `payload === undefined` deletes the provider.
*/
SuperJson.prototype.setProvider = function (providerName, payload) {
var changed = mutate_1.setProvider(this.document, providerName, payload);
if (changed) {
this.normalizedCache = undefined;
}
return changed;
};
SuperJson.prototype.swapProviderVariant = function (providerName, variant) {
var result = mutate_1.swapProviderVariant(this.document, providerName, variant);
if (result) {
var changed = mutate_1.swapProviderVariant(this.document, providerName, variant);
if (changed) {
this.normalizedCache = undefined;
}
return result;
return changed;
};

@@ -286,0 +322,0 @@ /**

{
"name": "@superfaceai/one-sdk",
"version": "0.0.30",
"version": "0.0.31",
"description": "Level 5 autonomous, self-driving API client, https://superface.ai",

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

Sorry, the diff of this file is not supported yet

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