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

@worldsibu/convector-core-model

Package Overview
Dependencies
Maintainers
1
Versions
187
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@worldsibu/convector-core-model - npm Package Compare versions

Comparing version 1.2.1-0-alpha.7fcb38d9 to 1.2.1-0-alpha.a462b675

6

dist/src/convector-model.d.ts

@@ -11,4 +11,8 @@ import * as yup from 'yup';

export declare abstract class ConvectorModel<T extends ConvectorModel<any>> {
static schema<T extends ConvectorModel<any>>(this: new (...args: any[]) => T): yup.ObjectSchema<FlatConvectorModel<T> & {
private static type;
static schema<T extends ConvectorModel<any>>(this: Function & {
prototype: T;
}): yup.ObjectSchema<FlatConvectorModel<T> & {
id: string;
type: string;
}>;

@@ -15,0 +19,0 @@ static getOne<T extends ConvectorModel<any>>(this: new (content: any) => T, id: string, type?: new (content: any) => T): Promise<T>;

28

dist/src/convector-model.js

@@ -23,4 +23,3 @@ "use strict";

ConvectorModel.schema = function () {
var instance = new this();
return yup.object().shape(tslib_1.__assign({ id: yup.string().required(), key: yup.string() }, validate_decorator_2.getPropertiesValidation(instance)));
return yup.object().shape(tslib_1.__assign({ id: yup.string().required(), type: yup.string() }, validate_decorator_2.getPropertiesValidation(this.prototype)));
};

@@ -53,3 +52,3 @@ ConvectorModel.getOne = function (id, type) {

type = this;
if (args[0] && args[0].prototype.__proto__.constructor === ConvectorModel) {
if (args[0] && 'type' in args[0] && args[0].type === ConvectorModel.type) {
type = args.shift();

@@ -133,3 +132,8 @@ }

if (!required_decorator_1.ensureRequired(this)) {
throw new Error("Model " + this.type + " is not complete\n" + JSON.stringify(this));
if (!this.id) {
throw new Error("Model " + this.type + " is missing the 'id' property \n" + JSON.stringify(this));
}
else {
throw new Error("Model " + this.type + " is not complete\n" + JSON.stringify(this) + ".\n Check your model definition for more details.");
}
}

@@ -151,3 +155,10 @@ convector_core_errors_1.InvalidIdError.test(this.id);

if (skipEmpty === void 0) { skipEmpty = false; }
var proto = Object.getPrototypeOf(this);
var protos = [];
var children = this;
do {
children = Object.getPrototypeOf(children);
protos.push(children);
} while (children['__proto__'].constructor.name !== ConvectorModel.name);
var descriptors = protos.reduce(function (result, proto) { return result.concat(Object.keys(proto)
.map(function (key) { return [key, Object.getOwnPropertyDescriptor(proto, key)]; })); }, []);
var base = Object.keys(this).concat('id')

@@ -160,5 +171,5 @@ .filter(function (k) { return !k.startsWith('_'); })

}, {});
return Object.keys(proto)
.reduce(function (result, key) {
var desc = Object.getOwnPropertyDescriptor(proto, key);
return descriptors
.reduce(function (result, _a) {
var key = _a[0], desc = _a[1];
var hasGetter = desc && typeof desc.get === 'function';

@@ -199,2 +210,3 @@ if (hasGetter) {

};
ConvectorModel.type = 'io.convector.model';
tslib_1.__decorate([

@@ -201,0 +213,0 @@ required_decorator_1.Required(),

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

export declare const defaultMetadataKey: any;
import 'reflect-metadata';
export declare function Default<T>(defaultValue: T): (target: any, key: string) => void;
export declare function getDefaults(obj: any): {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var defaultMetadataKey = Symbol('default');
var g = global;
exports.defaultMetadataKey = g.ConvectorDefaultMetadataKey || Symbol('default');
g.ConvectorDefaultMetadataKey = exports.defaultMetadataKey;
require("reflect-metadata");
function Default(defaultValue) {
return function (target, key) {
var defaults = Reflect.getMetadata(defaultMetadataKey, target) || {};
Reflect.defineMetadata(defaultMetadataKey, tslib_1.__assign({}, defaults, (_a = {}, _a[key] = defaultValue, _a)), target);
var defaults = Reflect.getMetadata(exports.defaultMetadataKey, target) || {};
Reflect.defineMetadata(exports.defaultMetadataKey, tslib_1.__assign({}, defaults, (_a = {}, _a[key] = defaultValue, _a)), target);
var _a;

@@ -15,3 +17,3 @@ };

function getDefaults(obj) {
var defaults = Reflect.getMetadata(defaultMetadataKey, obj);
var defaults = Reflect.getMetadata(exports.defaultMetadataKey, obj);
return !defaults ? {} : Object.keys(defaults)

@@ -18,0 +20,0 @@ .reduce(function (result, k) {

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

export declare const requiredMetadataKey: any;
import 'reflect-metadata';
export declare function Required(): (target: any, key: string) => void;
export declare function ensureRequired(obj: any): boolean;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var requiredMetadataKey = Symbol('required');
var g = global;
exports.requiredMetadataKey = g.ConvectorRequiredMetadataKey || Symbol('required');
g.ConvectorRequiredMetadataKey = exports.requiredMetadataKey;
require("reflect-metadata");
function Required() {
return function (target, key) {
var required = Reflect.getMetadata(requiredMetadataKey, target);
Reflect.defineMetadata(requiredMetadataKey, tslib_1.__assign({}, required, (_a = {}, _a[key] = true, _a)), target);
var required = Reflect.getMetadata(exports.requiredMetadataKey, target);
Reflect.defineMetadata(exports.requiredMetadataKey, tslib_1.__assign({}, required, (_a = {}, _a[key] = true, _a)), target);
var _a;

@@ -17,3 +19,3 @@ };

try {
required = Reflect.getMetadata(requiredMetadataKey, obj) || {};
required = Reflect.getMetadata(exports.requiredMetadataKey, obj) || {};
}

@@ -20,0 +22,0 @@ catch (e) {

import { Schema } from 'yup';
import 'reflect-metadata';
export declare const validateMetadataKey: any;
export declare function Validate<T>(input: Schema<T> | {

@@ -4,0 +5,0 @@ schema: () => Schema<T>;

@@ -5,7 +5,9 @@ "use strict";

require("reflect-metadata");
var validateMetadataKey = Symbol('validate');
var g = global;
exports.validateMetadataKey = g.ConvectorValidateMetadataKey || Symbol('validate');
g.ConvectorValidateMetadataKey = exports.validateMetadataKey;
function Validate(input) {
var schema = input;
if ('schema' in input) {
schema = input.schema;
schema = input.schema();
}

@@ -26,4 +28,4 @@ return function (target, key) {

Object.defineProperty(target, key, getSet);
var validated = Reflect.getMetadata(validateMetadataKey, target);
Reflect.defineMetadata(validateMetadataKey, tslib_1.__assign({}, validated, (_a = {}, _a[key] = schema, _a)), target);
var validated = Reflect.getMetadata(exports.validateMetadataKey, target);
Reflect.defineMetadata(exports.validateMetadataKey, tslib_1.__assign({}, validated, (_a = {}, _a[key] = schema, _a)), target);
var _a;

@@ -36,3 +38,3 @@ };

try {
validated = Reflect.getMetadata(validateMetadataKey, obj) || {};
validated = Reflect.getMetadata(exports.validateMetadataKey, obj) || {};
}

@@ -39,0 +41,0 @@ catch (e) {

{
"name": "@worldsibu/convector-core-model",
"version": "1.2.1-0-alpha.7fcb38d9",
"version": "1.2.1-0-alpha.a462b675",
"description": "Convector Model base class",

@@ -35,6 +35,6 @@ "license": "Apache-2.0",

"dependencies": {
"@worldsibu/convector-core-errors": "1.2.1-0-alpha.7fcb38d9",
"@worldsibu/convector-core-storage": "1.2.1-0-alpha.7fcb38d9",
"@worldsibu/convector-core-errors": "1.2.1-0-alpha.a462b675",
"@worldsibu/convector-core-storage": "1.2.1-0-alpha.a462b675",
"tslib": "^1.9.0",
"yup": "^0.24.1"
"yup": "^0.26.10"
},

@@ -41,0 +41,0 @@ "devDependencies": {

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