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

ts-jackson

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ts-jackson - npm Package Compare versions

Comparing version 1.3.0 to 1.3.1

249

dist/index.cjs.js

@@ -1,2 +0,249 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),require("reflect-metadata");var e=require("tslib"),r=require("lodash.get"),a=require("lodash.set");function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n,i=t(r),o=t(a);function s(e){var r=e.propName,a=e.propPath,t=e.propValue,n=e.json,i=e.serializableClass;if(void 0===t)throw new d({json:n,propName:r,serializableClass:i,propPath:a})}function l(e){return!!e&&void 0!==Reflect.getMetadata(n.TsJacksonSerializable,e)}!function(e){e.TsJacksonJsonProperty="ts-jackson:jsonproperty",e.TsJacksonSerializable="ts-jackson:serializable",e.DesignType="design:type",e.DesignParamTypes="design:paramtypes"}(n||(n={}));var u=function(r){function a(e){var a=r.call(this)||this;return a.name="SerializableError",a.message=e.name+" class should annotated with @"+m.name+" decorator",a}return e.__extends(a,r),a}(Error);function p(e){if(!l(e))throw new u(e)}function c(e){var r=e.propName,a=e.propValue,t=e.validate,n=e.serializableClass;if(!t(a))throw new v({propName:r,propValue:a,validate:t,serializableClass:n})}var f,d=function(r){function a(e){var a=e.propName,t=e.propPath,n=e.json,i="Property '"+a+"' is required in "+e.serializableClass.name+"\n but missing in "+JSON.stringify(n)+" by path "+t+".";return r.call(this,i)||this}return e.__extends(a,r),a}(Error),v=function(r){function a(e){var a=e.propName,t=e.propValue,n=e.validate,i="Property '"+a+"' = "+t+" in "+e.serializableClass.name+"\n failed to path "+n+" check";return r.call(this,i)||this}return e.__extends(a,r),a}(Error);function m(){return function(e){Reflect.defineMetadata(n.TsJacksonSerializable,{className:e.name},e)}}function y(r,a){for(var t=[],l=2;l<arguments.length;l++)t[l-2]=arguments[l];p(a);for(var u=Reflect.getMetadata(n.TsJacksonJsonProperty,a),f=new(a.bind.apply(a,e.__spreadArray([void 0],t))),d=[],v=0,m=Object.entries(u);v<m.length;v++){var y=m[v],b=y[0],z=y[1],g=i.default(r,z.path);z.required&&s({json:r,propName:b,propValue:g,serializableClass:a,propPath:z.path});var N=z.deserialize?z.deserialize(g):h(g,z.type,z.elementType);z.validate&&c({propName:b,propValue:N,validate:z.validate,serializableClass:a}),void 0!==N&&o.default(f,b,N),z.afterDeserialize&&d.push({propName:b,deserializedValue:N,afterDeserialize:z.afterDeserialize})}return d.forEach((function(e){var r=e.propName,a=e.deserializedValue,t=e.afterDeserialize;o.default(f,r,t(f,a))})),f}function h(e,r,a){if(null==e)return e;switch(null==r?void 0:r.name){case f.Date:return new Date(e);case f.Array:return e.map((function(e){return l(a)?y(e,a):e}));case f.Set:var t=e.map((function(e){return l(a)?y(e,a):e}));return new Set(t);case f.Boolean:return Boolean(e);case f.Number:return Number.parseInt(e);case f.String:return e;default:return l(r)?y(e,r):e}}function b(e){p(e.constructor);for(var r=Reflect.getMetadata(n.TsJacksonJsonProperty,e.constructor),a={},t=0,i=Object.entries(r);t<i.length;t++){var s=i[t],l=s[0],u=s[1],c=u.serialize?u.serialize(e[l]):z(e[l],u.type,u.elementType);o.default(a,u.path,c)}return a}function z(e,r,a){if(void 0===e)return e;switch(null==r?void 0:r.name){case f.Array:return e.map((function(e){return l(a)?b(e):e}));case f.Set:return Array.from(e.values()).map((function(e){return l(a)?b(e):e}));default:return l(r)?b(e):e}}!function(e){e.Array="Array",e.Set="Set",e.Boolean="Boolean",e.Date="Date",e.Number="Number",e.Object="Object",e.String="String"}(f||(f={}));var g=function(){function r(){}return r.prototype.serialize=function(){return b(this)},r.deserialize=function(r){for(var a=[],t=1;t<arguments.length;t++)a[t-1]=arguments[t];return y.apply(void 0,e.__spreadArray([r,this],a))},r=e.__decorate([m()],r)}();exports.JsonProperty=function(r){return void 0===r&&(r={}),function(a,t){var i="string"!=typeof r?r:{path:r},o=i.type||Reflect.getMetadata("design:type",a,t),s=Reflect.getMetadata(n.TsJacksonJsonProperty,a.constructor)||{};s[t]=e.__assign({type:o,name:t,path:t},i),Reflect.defineMetadata(n.TsJacksonJsonProperty,s,a.constructor)}},exports.Serializable=m,exports.SerializableEntity=g,exports.deserialize=y,exports.serialize=b;
'use strict'
Object.defineProperty(exports, '__esModule', { value: !0 }),
require('reflect-metadata')
var e = require('tslib'),
r = require('lodash.get'),
a = require('lodash.set')
function t(e) {
return e && 'object' == typeof e && 'default' in e ? e : { default: e }
}
var n,
i = t(r),
o = t(a)
function s(e) {
var r = e.propName,
a = e.propPath,
t = e.propValue,
n = e.json,
i = e.serializableClass
if (void 0 === t)
throw new d({ json: n, propName: r, serializableClass: i, propPath: a })
}
function l(e) {
return !!e && void 0 !== Reflect.getMetadata(n.TsJacksonSerializable, e)
}
!(function (e) {
;(e.TsJacksonJsonProperty = 'ts-jackson:jsonproperty'),
(e.TsJacksonSerializable = 'ts-jackson:serializable'),
(e.DesignType = 'design:type'),
(e.DesignParamTypes = 'design:paramtypes')
})(n || (n = {}))
var u = (function (r) {
function a(e) {
var a = r.call(this) || this
return (
(a.name = 'SerializableError'),
(a.message =
e.name + ' class should annotated with @' + y.name + ' decorator'),
a
)
}
return e.__extends(a, r), a
})(Error)
function p(e) {
if (!l(e)) throw new u(e)
}
function c(e) {
var r = e.propName,
a = e.propValue,
t = e.validate,
n = e.serializableClass
if (!t(a))
throw new v({
propName: r,
propValue: a,
validate: t,
serializableClass: n,
})
}
var f,
d = (function (r) {
function a(e) {
var a = e.propName,
t = e.propPath,
n = e.json,
i =
"Property '" +
a +
"' is required in " +
e.serializableClass.name +
'\n but missing in ' +
JSON.stringify(n) +
' by path ' +
t +
'.'
return r.call(this, i) || this
}
return e.__extends(a, r), a
})(Error),
v = (function (r) {
function a(e) {
var a = e.propName,
t = e.propValue,
n = e.validate,
i =
"Property '" +
a +
"' = " +
t +
' in ' +
e.serializableClass.name +
'\n failed to path ' +
n +
' check'
return r.call(this, i) || this
}
return e.__extends(a, r), a
})(Error)
function y() {
return function (e) {
Reflect.defineMetadata(n.TsJacksonSerializable, { className: e.name }, e)
}
}
function m(r, a) {
for (var t = [], l = 2; l < arguments.length; l++) t[l - 2] = arguments[l]
p(a)
for (
var u = Reflect.getMetadata(n.TsJacksonJsonProperty, a),
f = new (a.bind.apply(a, e.__spreadArray([void 0], t)))(),
d = 'string' == typeof r ? JSON.parse(r) : r,
v = [],
y = 0,
m = Object.entries(u);
y < m.length;
y++
) {
var b = m[y],
z = b[0],
g = b[1],
N = i.default(d, g.path)
g.required &&
s({
json: d,
propName: z,
propValue: N,
serializableClass: a,
propPath: g.path,
})
var J = g.deserialize ? g.deserialize(N) : h(N, g.type, g.elementType)
g.validate &&
c({
propName: z,
propValue: J,
validate: g.validate,
serializableClass: a,
}),
void 0 !== J && o.default(f, z, J),
g.afterDeserialize &&
v.push({
propName: z,
deserializedValue: J,
afterDeserialize: g.afterDeserialize,
})
}
return (
v.forEach(function (e) {
var r = e.propName,
a = e.deserializedValue,
t = e.afterDeserialize
o.default(f, r, t(f, a))
}),
f
)
}
function h(e, r, a) {
if (null == e) return e
switch (null == r ? void 0 : r.name) {
case f.Date:
return new Date(e)
case f.Array:
return e.map(function (e) {
return l(a) ? m(e, a) : e
})
case f.Set:
var t = e.map(function (e) {
return l(a) ? m(e, a) : e
})
return new Set(t)
case f.Boolean:
return Boolean(e)
case f.Number:
return Number.parseInt(e)
case f.String:
return e
default:
return l(r) ? m(e, r) : e
}
}
function b(e) {
p(e.constructor)
for (
var r = Reflect.getMetadata(n.TsJacksonJsonProperty, e.constructor),
a = {},
t = 0,
i = Object.entries(r);
t < i.length;
t++
) {
var s = i[t],
l = s[0],
u = s[1],
c = u.serialize ? u.serialize(e[l]) : z(e[l], u.type, u.elementType)
o.default(a, u.path, c)
}
return a
}
function z(e, r, a) {
if (void 0 === e) return e
switch (null == r ? void 0 : r.name) {
case f.Array:
return e.map(function (e) {
return l(a) ? b(e) : e
})
case f.Set:
return Array.from(e.values()).map(function (e) {
return l(a) ? b(e) : e
})
default:
return l(r) ? b(e) : e
}
}
!(function (e) {
;(e.Array = 'Array'),
(e.Set = 'Set'),
(e.Boolean = 'Boolean'),
(e.Date = 'Date'),
(e.Number = 'Number'),
(e.Object = 'Object'),
(e.String = 'String')
})(f || (f = {}))
var g = (function () {
function r() {}
return (
(r.prototype.serialize = function () {
return b(this)
}),
(r.deserialize = function (r) {
for (var a = [], t = 1; t < arguments.length; t++) a[t - 1] = arguments[t]
return m.apply(void 0, e.__spreadArray([r, this], a))
}),
(r = e.__decorate([y()], r))
)
})()
;(exports.JsonProperty = function (r) {
return (
void 0 === r && (r = {}),
function (a, t) {
var i = 'string' != typeof r ? r : { path: r },
o = i.type || Reflect.getMetadata('design:type', a, t),
s = Reflect.getMetadata(n.TsJacksonJsonProperty, a.constructor) || {}
;(s[t] = e.__assign({ type: o, name: t, path: t }, i)),
Reflect.defineMetadata(n.TsJacksonJsonProperty, s, a.constructor)
}
)
}),
(exports.Serializable = y),
(exports.SerializableEntity = g),
(exports.deserialize = m),
(exports.serialize = b)
//# sourceMappingURL=index.cjs.js.map

10

dist/index.d.ts

@@ -1,5 +0,5 @@

export { default as Serializable } from "./src/Serializable";
export { default as deserialize } from "./src/deserialize";
export { default as serialize } from "./src/serialize";
export { default as JsonProperty } from "./src/JsonProperty";
export { default as SerializableEntity } from "./src/SerializableEntity";
export { default as deserialize } from './src/deserialize'
export { default as JsonProperty } from './src/JsonProperty'
export { default as Serializable } from './src/Serializable'
export { default as SerializableEntity } from './src/SerializableEntity'
export { default as serialize } from './src/serialize'

@@ -1,2 +0,250 @@

import"reflect-metadata";import{__extends as e,__spreadArray as r,__assign as a,__decorate as t}from"tslib";import n from"lodash.get";import i from"lodash.set";function o(e){var r=e.propName,a=e.propPath,t=e.propValue,n=e.json,i=e.serializableClass;if(void 0===t)throw new d({json:n,propName:r,serializableClass:i,propPath:a})}var s;function l(e){return!!e&&void 0!==Reflect.getMetadata(s.TsJacksonSerializable,e)}!function(e){e.TsJacksonJsonProperty="ts-jackson:jsonproperty",e.TsJacksonSerializable="ts-jackson:serializable",e.DesignType="design:type",e.DesignParamTypes="design:paramtypes"}(s||(s={}));var p=function(r){function a(e){var a=r.call(this)||this;return a.name="SerializableError",a.message=e.name+" class should annotated with @"+h.name+" decorator",a}return e(a,r),a}(Error);function u(e){if(!l(e))throw new p(e)}function c(e){var r=e.propName,a=e.propValue,t=e.validate,n=e.serializableClass;if(!t(a))throw new m({propName:r,propValue:a,validate:t,serializableClass:n})}var f,d=function(r){function a(e){var a=e.propName,t=e.propPath,n=e.json,i="Property '"+a+"' is required in "+e.serializableClass.name+"\n but missing in "+JSON.stringify(n)+" by path "+t+".";return r.call(this,i)||this}return e(a,r),a}(Error),m=function(r){function a(e){var a=e.propName,t=e.propValue,n=e.validate,i="Property '"+a+"' = "+t+" in "+e.serializableClass.name+"\n failed to path "+n+" check";return r.call(this,i)||this}return e(a,r),a}(Error);function h(){return function(e){Reflect.defineMetadata(s.TsJacksonSerializable,{className:e.name},e)}}function v(e,a){for(var t=[],l=2;l<arguments.length;l++)t[l-2]=arguments[l];u(a);for(var p=Reflect.getMetadata(s.TsJacksonJsonProperty,a),f=new(a.bind.apply(a,r([void 0],t))),d=[],m=0,h=Object.entries(p);m<h.length;m++){var v=h[m],b=v[0],z=v[1],g=n(e,z.path);z.required&&o({json:e,propName:b,propValue:g,serializableClass:a,propPath:z.path});var N=z.deserialize?z.deserialize(g):y(g,z.type,z.elementType);z.validate&&c({propName:b,propValue:N,validate:z.validate,serializableClass:a}),void 0!==N&&i(f,b,N),z.afterDeserialize&&d.push({propName:b,deserializedValue:N,afterDeserialize:z.afterDeserialize})}return d.forEach((function(e){var r=e.propName,a=e.deserializedValue,t=e.afterDeserialize;i(f,r,t(f,a))})),f}function y(e,r,a){if(null==e)return e;switch(null==r?void 0:r.name){case f.Date:return new Date(e);case f.Array:return e.map((function(e){return l(a)?v(e,a):e}));case f.Set:var t=e.map((function(e){return l(a)?v(e,a):e}));return new Set(t);case f.Boolean:return Boolean(e);case f.Number:return Number.parseInt(e);case f.String:return e;default:return l(r)?v(e,r):e}}function b(e){u(e.constructor);for(var r=Reflect.getMetadata(s.TsJacksonJsonProperty,e.constructor),a={},t=0,n=Object.entries(r);t<n.length;t++){var o=n[t],l=o[0],p=o[1],c=p.serialize?p.serialize(e[l]):z(e[l],p.type,p.elementType);i(a,p.path,c)}return a}function z(e,r,a){if(void 0===e)return e;switch(null==r?void 0:r.name){case f.Array:return e.map((function(e){return l(a)?b(e):e}));case f.Set:return Array.from(e.values()).map((function(e){return l(a)?b(e):e}));default:return l(r)?b(e):e}}function g(e){return void 0===e&&(e={}),function(r,t){var n="string"!=typeof e?e:{path:e},i=n.type||Reflect.getMetadata("design:type",r,t),o=Reflect.getMetadata(s.TsJacksonJsonProperty,r.constructor)||{};o[t]=a({type:i,name:t,path:t},n),Reflect.defineMetadata(s.TsJacksonJsonProperty,o,r.constructor)}}!function(e){e.Array="Array",e.Set="Set",e.Boolean="Boolean",e.Date="Date",e.Number="Number",e.Object="Object",e.String="String"}(f||(f={}));var N=function(){function e(){}return e.prototype.serialize=function(){return b(this)},e.deserialize=function(e){for(var a=[],t=1;t<arguments.length;t++)a[t-1]=arguments[t];return v.apply(void 0,r([e,this],a))},e=t([h()],e)}();export{g as JsonProperty,h as Serializable,N as SerializableEntity,v as deserialize,b as serialize};
import 'reflect-metadata'
import {
__extends as e,
__spreadArray as r,
__assign as a,
__decorate as t,
} from 'tslib'
import n from 'lodash.get'
import i from 'lodash.set'
function o(e) {
var r = e.propName,
a = e.propPath,
t = e.propValue,
n = e.json,
i = e.serializableClass
if (void 0 === t)
throw new d({ json: n, propName: r, serializableClass: i, propPath: a })
}
var s
function l(e) {
return !!e && void 0 !== Reflect.getMetadata(s.TsJacksonSerializable, e)
}
!(function (e) {
;(e.TsJacksonJsonProperty = 'ts-jackson:jsonproperty'),
(e.TsJacksonSerializable = 'ts-jackson:serializable'),
(e.DesignType = 'design:type'),
(e.DesignParamTypes = 'design:paramtypes')
})(s || (s = {}))
var p = (function (r) {
function a(e) {
var a = r.call(this) || this
return (
(a.name = 'SerializableError'),
(a.message =
e.name + ' class should annotated with @' + h.name + ' decorator'),
a
)
}
return e(a, r), a
})(Error)
function u(e) {
if (!l(e)) throw new p(e)
}
function c(e) {
var r = e.propName,
a = e.propValue,
t = e.validate,
n = e.serializableClass
if (!t(a))
throw new m({
propName: r,
propValue: a,
validate: t,
serializableClass: n,
})
}
var f,
d = (function (r) {
function a(e) {
var a = e.propName,
t = e.propPath,
n = e.json,
i =
"Property '" +
a +
"' is required in " +
e.serializableClass.name +
'\n but missing in ' +
JSON.stringify(n) +
' by path ' +
t +
'.'
return r.call(this, i) || this
}
return e(a, r), a
})(Error),
m = (function (r) {
function a(e) {
var a = e.propName,
t = e.propValue,
n = e.validate,
i =
"Property '" +
a +
"' = " +
t +
' in ' +
e.serializableClass.name +
'\n failed to path ' +
n +
' check'
return r.call(this, i) || this
}
return e(a, r), a
})(Error)
function h() {
return function (e) {
Reflect.defineMetadata(s.TsJacksonSerializable, { className: e.name }, e)
}
}
function v(e, a) {
for (var t = [], l = 2; l < arguments.length; l++) t[l - 2] = arguments[l]
u(a)
for (
var p = Reflect.getMetadata(s.TsJacksonJsonProperty, a),
f = new (a.bind.apply(a, r([void 0], t)))(),
d = 'string' == typeof e ? JSON.parse(e) : e,
m = [],
h = 0,
v = Object.entries(p);
h < v.length;
h++
) {
var b = v[h],
z = b[0],
g = b[1],
N = n(d, g.path)
g.required &&
o({
json: d,
propName: z,
propValue: N,
serializableClass: a,
propPath: g.path,
})
var J = g.deserialize ? g.deserialize(N) : y(N, g.type, g.elementType)
g.validate &&
c({
propName: z,
propValue: J,
validate: g.validate,
serializableClass: a,
}),
void 0 !== J && i(f, z, J),
g.afterDeserialize &&
m.push({
propName: z,
deserializedValue: J,
afterDeserialize: g.afterDeserialize,
})
}
return (
m.forEach(function (e) {
var r = e.propName,
a = e.deserializedValue,
t = e.afterDeserialize
i(f, r, t(f, a))
}),
f
)
}
function y(e, r, a) {
if (null == e) return e
switch (null == r ? void 0 : r.name) {
case f.Date:
return new Date(e)
case f.Array:
return e.map(function (e) {
return l(a) ? v(e, a) : e
})
case f.Set:
var t = e.map(function (e) {
return l(a) ? v(e, a) : e
})
return new Set(t)
case f.Boolean:
return Boolean(e)
case f.Number:
return Number.parseInt(e)
case f.String:
return e
default:
return l(r) ? v(e, r) : e
}
}
function b(e) {
u(e.constructor)
for (
var r = Reflect.getMetadata(s.TsJacksonJsonProperty, e.constructor),
a = {},
t = 0,
n = Object.entries(r);
t < n.length;
t++
) {
var o = n[t],
l = o[0],
p = o[1],
c = p.serialize ? p.serialize(e[l]) : z(e[l], p.type, p.elementType)
i(a, p.path, c)
}
return a
}
function z(e, r, a) {
if (void 0 === e) return e
switch (null == r ? void 0 : r.name) {
case f.Array:
return e.map(function (e) {
return l(a) ? b(e) : e
})
case f.Set:
return Array.from(e.values()).map(function (e) {
return l(a) ? b(e) : e
})
default:
return l(r) ? b(e) : e
}
}
function g(e) {
return (
void 0 === e && (e = {}),
function (r, t) {
var n = 'string' != typeof e ? e : { path: e },
i = n.type || Reflect.getMetadata('design:type', r, t),
o = Reflect.getMetadata(s.TsJacksonJsonProperty, r.constructor) || {}
;(o[t] = a({ type: i, name: t, path: t }, n)),
Reflect.defineMetadata(s.TsJacksonJsonProperty, o, r.constructor)
}
)
}
!(function (e) {
;(e.Array = 'Array'),
(e.Set = 'Set'),
(e.Boolean = 'Boolean'),
(e.Date = 'Date'),
(e.Number = 'Number'),
(e.Object = 'Object'),
(e.String = 'String')
})(f || (f = {}))
var N = (function () {
function e() {}
return (
(e.prototype.serialize = function () {
return b(this)
}),
(e.deserialize = function (e) {
for (var a = [], t = 1; t < arguments.length; t++) a[t - 1] = arguments[t]
return v.apply(void 0, r([e, this], a))
}),
(e = t([h()], e))
)
})()
export {
g as JsonProperty,
h as Serializable,
N as SerializableEntity,
v as deserialize,
b as serialize,
}
//# sourceMappingURL=index.esm.js.map
declare type Params = {
propName: string;
propPath: string;
propValue: unknown;
json: Record<string, unknown>;
serializableClass: new (...params: Array<unknown>) => unknown;
};
export default function assertRequired({ propName, propPath, propValue, json, serializableClass, }: Params): void;
export {};
propName: string
propPath: string
propValue: unknown
json: Record<string, unknown>
serializableClass: new (...params: Array<unknown>) => unknown
}
export default function assertRequired({
propName,
propPath,
propValue,
json,
serializableClass,
}: Params): void
export {}

@@ -1,1 +0,3 @@

export default function assertSerializable(target: (new (...args: any[]) => unknown) | Function): void;
export default function assertSerializable(
target: (new (...args: any[]) => unknown) | Function
): void
declare type Params = {
propName: string;
propValue: unknown;
validate: (property: unknown) => boolean;
serializableClass: new (...params: Array<unknown>) => unknown;
};
export default function assertValid({ propName, propValue, validate, serializableClass, }: Params): void;
export {};
propName: string
propValue: unknown
validate: (property: unknown) => boolean
serializableClass: new (...params: Array<unknown>) => unknown
}
export default function assertValid({
propName,
propValue,
validate,
serializableClass,
}: Params): void
export {}

@@ -1,3 +0,3 @@

export { default as assertRequired } from './assertRequired';
export { default as assertSerializable } from './assertSerializable';
export { default as assertValid } from './assertValid';
export { default as assertRequired } from './assertRequired'
export { default as assertSerializable } from './assertSerializable'
export { default as assertValid } from './assertValid'

@@ -1,1 +0,3 @@

export default function checkSerializable(target: (new (...params: any[]) => unknown) | Function): boolean;
export default function checkSerializable(
target: (new (...params: any[]) => unknown) | Function
): boolean

@@ -1,3 +0,3 @@

export { default as RequiredPropertyError } from './RequiredPropertyError';
export { default as SerializableError } from './SerializableError';
export { default as ValidatePropertyError } from './ValidatePropertyError';
export { default as RequiredPropertyError } from './RequiredPropertyError'
export { default as SerializableError } from './SerializableError'
export { default as ValidatePropertyError } from './ValidatePropertyError'
declare type Params = {
propName: string;
propPath: string;
json: Record<string, unknown>;
serializableClass: new (...params: Array<unknown>) => unknown;
};
propName: string
propPath: string
json: Record<string, unknown>
serializableClass: new (...params: Array<unknown>) => unknown
}
export default class RequiredPropertyError extends Error {
constructor({ propName, propPath, json, serializableClass }: Params);
constructor({ propName, propPath, json, serializableClass }: Params)
}
export {};
export {}
export default class SerializableError extends Error {
constructor(target: (new (...args: any[]) => unknown) | Function);
constructor(target: (new (...args: any[]) => unknown) | Function)
}
declare type Params = {
propName: string;
propValue: unknown;
validate: (property: unknown) => boolean;
serializableClass: new (...params: Array<unknown>) => unknown;
};
propName: string
propValue: unknown
validate: (property: unknown) => boolean
serializableClass: new (...params: Array<unknown>) => unknown
}
export default class ValidatePropertyError extends Error {
constructor({ propName, propValue, validate, serializableClass }: Params);
constructor({ propName, propValue, validate, serializableClass }: Params)
}
export {};
export {}

@@ -1,5 +0,5 @@

export * from './asserts';
export { default as checkSerializable } from './checkSerializable';
export * from './errors';
export * from './ReflectMetaDataKeys';
export * from './Types';
export * from './asserts'
export { default as checkSerializable } from './checkSerializable'
export * from './errors'
export * from './ReflectMetaDataKeys'
export * from './Types'
export declare enum ReflectMetaDataKeys {
TsJacksonJsonProperty = "ts-jackson:jsonproperty",
TsJacksonSerializable = "ts-jackson:serializable",
DesignType = "design:type",
DesignParamTypes = "design:paramtypes"
TsJacksonJsonProperty = 'ts-jackson:jsonproperty',
TsJacksonSerializable = 'ts-jackson:serializable',
DesignType = 'design:type',
DesignParamTypes = 'design:paramtypes',
}
export declare enum Types {
Array = "Array",
Set = "Set",
Boolean = "Boolean",
Date = "Date",
Number = "Number",
Object = "Object",
String = "String"
Array = 'Array',
Set = 'Set',
Boolean = 'Boolean',
Date = 'Date',
Number = 'Number',
Object = 'Object',
String = 'String',
}

@@ -1,6 +0,6 @@

import 'reflect-metadata';
import 'reflect-metadata'
/**
* Function to deserialize json to Serializable class
*
* @param {Record<string, unknown>} json
* @param {Record<string, unknown> | string} json
* @param serializableClass Class to which json should be serialized

@@ -11,2 +11,6 @@ * @param args an arguments to be provided to constructor.

*/
export default function deserialize<T, U extends Array<unknown>>(json: Record<string, unknown>, serializableClass: new (...params: [...U]) => T, ...args: U): T;
export default function deserialize<T, U extends Array<unknown>>(
json: Record<string, unknown> | string,
serializableClass: new (...args: [...U]) => T,
...args: U
): T
/**
* @author Ilias Gazdaliev <invimind@gmail.com>
*/
import 'reflect-metadata';
import 'reflect-metadata'
/**

@@ -23,16 +23,19 @@ * JsonProperty params

declare type Params<P> = {
path?: string;
required?: boolean;
type?: new (...params: Array<unknown>) => unknown;
elementType?: new (...args: any[]) => unknown;
validate?: (property: P) => boolean;
deserialize?: (jsonValue: unknown) => P;
serialize?: (property: P) => unknown;
afterDeserialize?: (deserializedInstance: InstanceType<new (...args: any[]) => unknown>, propertyValue: P) => P;
};
path?: string
required?: boolean
type?: new (...params: Array<unknown>) => unknown
elementType?: new (...args: any[]) => unknown
validate?: (property: P) => boolean
deserialize?: (jsonValue: unknown) => P
serialize?: (property: P) => unknown
afterDeserialize?: (
deserializedInstance: InstanceType<new (...args: any[]) => unknown>,
propertyValue: P
) => P
}
export declare type JsonPropertyMetadata<P = unknown> = {
name: string;
path: string;
type: new (...params: any[]) => unknown;
} & Params<P>;
name: string
path: string
type: new (...params: any[]) => unknown
} & Params<P>
/**

@@ -42,3 +45,5 @@ * Decorator. Collects annotated property metadata.

*/
export default function JsonProperty<P = unknown>(arg?: Params<P> | string): (object: Object, propertyName: string) => void;
export {};
export default function JsonProperty<P = unknown>(
arg?: Params<P> | string
): (object: Object, propertyName: string) => void
export {}
/**
* @author Ilias Gazdaliev <invimind@gmail.com>
*/
import 'reflect-metadata';
declare type Params = {};
import 'reflect-metadata'
declare type Params = {}
export declare type SerializableMetadata = {
className: string;
} & Params;
className: string
} & Params
/**

@@ -14,3 +14,5 @@ * Decorator for marking serializable classes

*/
export default function Serializable(): (target: new (...params: Array<unknown>) => unknown) => void;
export {};
export default function Serializable(): (
target: new (...params: Array<unknown>) => unknown
) => void
export {}

@@ -7,6 +7,10 @@ /**

export default class SerializableEntity {
serialize(): Record<string, unknown>;
static deserialize<T, U extends Array<unknown>>(this: {
new (...params: [...U]): T;
}, json: Record<string, unknown>, ...args: U): T;
serialize(): Record<string, unknown>
static deserialize<T, U extends Array<unknown>>(
this: {
new (...params: [...U]): T
},
json: Record<string, unknown>,
...args: U
): T
}

@@ -7,2 +7,4 @@ /**

*/
export default function serialize<T extends new (...args: any[]) => unknown>(instance: InstanceType<T>): Record<string, unknown>;
export default function serialize<T extends new (...args: any[]) => unknown>(
instance: InstanceType<T>
): Record<string, unknown>
{
"name": "ts-jackson",
"version": "1.3.0",
"version": "1.3.1",
"author": "Ilias Gazdaliev",

@@ -12,4 +12,5 @@ "description": "",

"build": "rollup -c",
"postbuild": "npm run tsc-release",
"postbuild": "npm run tsc-release && npm run pretify-dist",
"tsc-release": "tsc --build ts-config.release.json",
"pretify-dist": "cd ./dist && prettier --write .",
"test": "jest",

@@ -16,0 +17,0 @@ "watch": "tsc --watch"

@@ -177,3 +177,3 @@ # ts-jackson

*
* @param {Record<string, unknown>} json
* @param {Record<string, unknown> | string} json
* @param serializableClass Class to which json should be serialized

@@ -185,6 +185,6 @@ * @param args an arguments to be provided to constructor.

export default function deserialize<T, U extends Array<unknown>>(
json: Record<string, unknown>,
serializableClass: new (...params: [...U]) => T,
json: Record<string, unknown> | string,
serializableClass: new (...args: [...U]) => T,
...args: U
): T { }
): T
```

@@ -191,0 +191,0 @@ #### serialize

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