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

dryvjs

Package Overview
Dependencies
Maintainers
1
Versions
88
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dryvjs - npm Package Compare versions

Comparing version 1.0.0-pre-3 to 1.0.0-pre-4

dist/core/isDryvValidatable.d.ts

2

dist/core/dryvProxy.js
import { dryvProxyHandler } from './dryvProxyHandler';
import { defaultDryvOptions } from './defaultDryvOptions';
import { isDryvProxy } from '@/core';
import { isDryvProxy } from './isDryvProxy';
export function dryvProxy(model, field, session, options) {

@@ -5,0 +5,0 @@ if (!model) {

@@ -1,100 +0,96 @@

import { dryvProxy, isDryvProxy } from '.'
import { isDryvValidatable } from '@/core'
import { dryvValidatableObject } from './dryvValidatableObject'
import { dryvValidatableValue } from './dryvValidatableValue'
import { dryvProxy, isDryvProxy } from '.';
import { isDryvValidatable } from './isDryvValidatable';
import { dryvValidatableObject } from './dryvValidatableObject';
import { dryvValidatableValue } from './dryvValidatableValue';
export function dryvProxyHandler(field, session, options) {
const _excludedFields = {}
let _dryv = null
return {
get(target, fieldSymbol, receiver) {
const fieldName = String(fieldSymbol)
if (fieldName === '$dryv') {
return getDryv(receiver)
}
if (isExcludedField(fieldName)) {
return Reflect.get(target, fieldName, receiver)
}
const originalValue = Reflect.get(target, fieldName, receiver)
const field = fieldName
let resultValue
if (originalValue && typeof originalValue === 'object') {
resultValue = ensureObjectProxy(originalValue, field, receiver, session)
if (resultValue !== originalValue) {
Reflect.set(target, fieldName, resultValue)
const _excludedFields = {};
let _dryv = null;
return {
get(target, fieldSymbol, receiver) {
const fieldName = String(fieldSymbol);
if (fieldName === '$dryv') {
return getDryv(receiver);
}
if (isExcludedField(fieldName)) {
return Reflect.get(target, fieldName, receiver);
}
const originalValue = Reflect.get(target, fieldName, receiver);
const field = fieldName;
let resultValue;
if (originalValue && typeof originalValue === 'object') {
resultValue = ensureObjectProxy(originalValue, field, receiver, session);
if (resultValue !== originalValue) {
Reflect.set(target, fieldName, resultValue);
}
}
else if (typeof originalValue !== 'function') {
ensureValueProxy(field, receiver);
resultValue = originalValue;
}
return resultValue;
},
set(target, fieldSymbol, value, receiver) {
const fieldName = String(fieldSymbol);
if (fieldName === '$dryv') {
throw new Error('The $dryv property is read-only.');
}
const field = fieldName;
if (typeof value === 'function') {
return Reflect.set(target, field, value);
}
if (isExcludedField(fieldName)) {
return Reflect.set(target, field, value);
}
const originalValue = Reflect.get(target, field, receiver);
if (!value && isDryvProxy(originalValue)) {
originalValue.$dryv.parent = undefined;
}
let targetValue;
let proxy = undefined;
if (typeof value === 'object') {
targetValue = ensureObjectProxy(value, field, receiver, session);
}
else {
proxy = ensureValueProxy(field, receiver);
targetValue = value;
}
const result = Reflect.set(target, field, targetValue);
proxy === null || proxy === void 0 ? void 0 : proxy.validate().catch(console.error);
return result;
}
} else if (typeof originalValue !== 'function') {
ensureValueProxy(field, receiver)
resultValue = originalValue
}
return resultValue
},
set(target, fieldSymbol, value, receiver) {
const fieldName = String(fieldSymbol)
if (fieldName === '$dryv') {
throw new Error('The $dryv property is read-only.')
}
const field = fieldName
if (value && typeof value === 'function') {
return Reflect.set(target, field, value)
}
if (isExcludedField(fieldName)) {
return Reflect.set(target, field, value)
}
const originalValue = Reflect.get(target, field, receiver)
if (!value && isDryvProxy(originalValue)) {
originalValue.$dryv.parent = undefined
}
let targetValue
let proxy = undefined
if (typeof value === 'object') {
targetValue = ensureObjectProxy(value, field, receiver, session)
} else {
proxy = ensureValueProxy(field, receiver)
targetValue = value
}
const result = Reflect.set(target, field, targetValue)
proxy === null || proxy === void 0 ? void 0 : proxy.validate().catch(console.error)
return result
};
function ensureObjectProxy(value, field, receiver, session) {
const proxy = !isDryvProxy(value)
? dryvProxy(value, field, session, options)
: value;
const dryv = getDryv(receiver);
dryv.value[field] = proxy.$dryv.value;
proxy.$dryv.parent = dryv;
return proxy;
}
}
function ensureObjectProxy(value, field, receiver, session) {
const proxy = !isDryvProxy(value) ? dryvProxy(value, field, session, options) : value
const dryv = getDryv(receiver)
dryv.value[field] = proxy.$dryv.value
proxy.$dryv.parent = dryv
return proxy
}
function ensureValueProxy(field, receiver) {
const dryv = getDryv(receiver)
const dryvObject = dryv.value
if (isDryvValidatable(dryvObject[field])) {
return dryvObject[field]
function ensureValueProxy(field, receiver) {
const dryv = getDryv(receiver);
const dryvObject = dryv.value;
if (isDryvValidatable(dryvObject[field])) {
return dryvObject[field];
}
const validatable = dryvValidatableValue(field, dryv, options, () => receiver[field], (value) => (receiver[field] = value));
const proxy = options.objectWrapper(validatable);
dryvObject[field] = proxy;
return proxy;
}
const validatable = dryvValidatableValue(
field,
dryv,
options,
() => receiver[field],
(value) => (receiver[field] = value)
)
const proxy = options.objectWrapper(validatable)
dryvObject[field] = proxy
return proxy
}
function getDryv(model) {
if (!_dryv) {
_dryv = dryvValidatableObject(field, session, model, options)
function getDryv(model) {
if (!_dryv) {
_dryv = dryvValidatableObject(field, session, model, options);
}
return _dryv;
}
return _dryv
}
function isExcludedField(field) {
var _a
if (_excludedFields[field] === undefined) {
_excludedFields[field] = !!((_a = options.excludedFields) === null || _a === void 0
? void 0
: _a.find((regexp) => (regexp === null || regexp === void 0 ? void 0 : regexp.test(field))))
function isExcludedField(field) {
var _a;
if (_excludedFields[field] === undefined) {
_excludedFields[field] = !!((_a = options.excludedFields) === null || _a === void 0 ? void 0 : _a.find((regexp) => regexp === null || regexp === void 0 ? void 0 : regexp.test(field)));
}
return _excludedFields[field];
}
return _excludedFields[field]
}
}
//# sourceMappingURL=dryvProxyHandler.js.map
//# sourceMappingURL=dryvProxyHandler.js.map

@@ -10,4 +10,4 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

};
import { isDryvValidatable } from '@/core';
import { dryvValidatableValue } from '@/core/dryvValidatableValue';
import { isDryvValidatable } from './isDryvValidatable';
import { dryvValidatableValue } from './dryvValidatableValue';
export function dryvValidatableObject(field, parentOrSession, model, options) {

@@ -14,0 +14,0 @@ let _parent = isDryvValidatable(parentOrSession)

export * from './dryvProxy';
export * from './dryvValidationSession';
export * from './isDryvValidatableValue';
export * from './isDryvValidatable';
export * from './isDryvProxy';

@@ -5,0 +5,0 @@ export * from './dryvOptions';

export * from './dryvProxy';
export * from './dryvValidationSession';
export * from './isDryvValidatableValue';
export * from './isDryvValidatable';
export * from './isDryvProxy';

@@ -5,0 +5,0 @@ export * from './dryvOptions';

{
"name": "dryvjs",
"version": "1.0.0-pre-3",
"version": "1.0.0-pre-4",
"main": "dist/index.js",

@@ -5,0 +5,0 @@ "types": "dist/index.d.ts",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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