Socket
Socket
Sign inDemoInstall

@orion-js/models

Package Overview
Dependencies
3
Maintainers
3
Versions
62
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.0.37 to 3.0.38

3

lib/createModel/clone.d.ts

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

import { CreateModel, CloneOptions } from '../types';
import { CreateModel, CloneOptions, CreateModelOptions } from '../types';
interface CloneInfo {

@@ -6,4 +6,5 @@ createModel: CreateModel;

getResolvers: () => any;
modelOptions: CreateModelOptions;
}
declare const clone: (cloneInfo: CloneInfo, options: CloneOptions) => import("../types").Model;
export default clone;

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

const clone = (cloneInfo, options) => {
const { createModel, getSchema, getResolvers } = cloneInfo;
const { createModel, getSchema, getResolvers, modelOptions } = cloneInfo;
return createModel({
name: options.name,
clean: modelOptions.clean,
validate: modelOptions.validate,
resolvers: () => {

@@ -14,0 +16,0 @@ if (!options.extendResolvers)

@@ -7,25 +7,44 @@ "use strict";

const index_1 = __importDefault(require("./index"));
it('cloned model should pick fields correctly', async () => {
const type = {
type: String
};
const model1 = (0, index_1.default)({
name: 'AModel',
schema: {
a: type,
b: type,
c: type
}
describe('Cloning models', () => {
it('cloned model should pick fields correctly', async () => {
const type = {
type: String
};
const model1 = (0, index_1.default)({
name: 'AModel',
schema: {
a: type,
b: type,
c: type
}
});
const model2 = model1.clone({
name: 'Cloned2',
pickFields: ['a', 'b']
});
const model3 = model2.clone({
name: 'Cloned3',
omitFields: ['b']
});
const schema = model3.getSchema();
const keys = Object.keys(schema).filter(key => !key.startsWith('__'));
expect(keys).toEqual(['a']);
});
const model2 = model1.clone({
name: 'Cloned2',
pickFields: ['a', 'b']
it('should pass __clean and __validate to the cloned model schema', () => {
const clean = name => `clean ${name}`;
const model1 = (0, index_1.default)({
name: 'Model1',
schema: {
name: { type: String }
},
clean
});
const model2 = model1.clone({
name: 'Model2'
});
const schema1 = model1.getSchema();
const schema2 = model2.getSchema();
expect(schema1.__clean).toBe(clean);
expect(schema2.__clean).toBe(clean);
});
const model3 = model2.clone({
name: 'Cloned3',
omitFields: ['b']
});
const schema = model3.getSchema();
const keys = Object.keys(schema).filter(key => !key.startsWith('__'));
expect(keys).toEqual(['a']);
});

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

getSchema,
getResolvers
getResolvers,
modelOptions
}, cloneOptions);

@@ -81,0 +82,0 @@ }

{
"name": "@orion-js/models",
"version": "3.0.37",
"version": "3.0.38",
"main": "lib/index.js",

@@ -39,3 +39,3 @@ "types": "lib/index.d.ts",

},
"gitHead": "741691d7603f3d42e6e3e8fa9dc0f9de51a29424"
"gitHead": "00903f1488b72e13b7d5031a916eb897d0d80e0c"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc