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

@feathersjs/schema

Package Overview
Dependencies
Maintainers
3
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@feathersjs/schema - npm Package Compare versions

Comparing version 5.0.0-pre.33 to 5.0.0-pre.34

15

CHANGELOG.md

@@ -6,2 +6,17 @@ # Change Log

# [5.0.0-pre.34](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.33...v5.0.0-pre.34) (2022-12-14)
### Bug Fixes
- **core:** `context.type` for around hooks ([#2890](https://github.com/feathersjs/feathers/issues/2890)) ([d606ac6](https://github.com/feathersjs/feathers/commit/d606ac660fd5335c95206784fea36530dd2e851a))
- **core:** Improve service option usage and method option typings ([#2902](https://github.com/feathersjs/feathers/issues/2902)) ([164d75c](https://github.com/feathersjs/feathers/commit/164d75c0f11139a316baa91f1762de8f8eb7da2d))
- **schema:** Allow query schemas with no properties, error on unsupported types ([#2904](https://github.com/feathersjs/feathers/issues/2904)) ([b66c734](https://github.com/feathersjs/feathers/commit/b66c734357478f51b2d38fa7f3eee08640cea26e))
### Features
- **adapter:** Add patch data type to adapters and refactor AdapterBase usage ([#2906](https://github.com/feathersjs/feathers/issues/2906)) ([9ddc2e6](https://github.com/feathersjs/feathers/commit/9ddc2e6b028f026f939d6af68125847e5c6734b4))
- **cli:** Use separate patch schema and types ([#2916](https://github.com/feathersjs/feathers/issues/2916)) ([7088af6](https://github.com/feathersjs/feathers/commit/7088af64a539dc7f1a016d832b77b98aaaf92603))
- **schema:** Split resolver options and property resolvers ([#2889](https://github.com/feathersjs/feathers/issues/2889)) ([4822c94](https://github.com/feathersjs/feathers/commit/4822c949812e5a1dceff3c62b2f9de4781b4d601))
- **schema:** Virtual property resolvers ([#2900](https://github.com/feathersjs/feathers/issues/2900)) ([7d03b57](https://github.com/feathersjs/feathers/commit/7d03b57ae2f633bdd4a368e0d5955011fbd6c329))
# [5.0.0-pre.33](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.32...v5.0.0-pre.33) (2022-11-08)

@@ -8,0 +23,0 @@

4

lib/default-schemas.d.ts

@@ -118,3 +118,3 @@ import { FromSchema } from 'json-schema-to-ts';

};
export declare type AuthenticationConfiguration = FromSchema<typeof authenticationSettingsSchema>;
export type AuthenticationConfiguration = FromSchema<typeof authenticationSettingsSchema>;
export declare const sqlSettingsSchema: {

@@ -506,2 +506,2 @@ readonly type: "object";

};
export declare type DefaultAppConfiguration = FromSchema<typeof defaultAppConfiguration>;
export type DefaultAppConfiguration = FromSchema<typeof defaultAppConfiguration>;
import { HookContext, NextFunction } from '@feathersjs/feathers';
import { Resolver } from '../resolver';
export declare type ResolverSetting<H extends HookContext> = Resolver<any, H> | Resolver<any, H>[];
export type ResolverSetting<H extends HookContext> = Resolver<any, H> | Resolver<any, H>[];
export declare const resolveQuery: <T, H extends HookContext<import("@feathersjs/feathers").Application<any, any>, any>>(...resolvers: Resolver<T, H>[]) => (context: H, next?: NextFunction) => Promise<any>;

@@ -11,3 +11,3 @@ export declare const resolveData: <T, H extends HookContext<import("@feathersjs/feathers").Application<any, any>, any>>(...resolvers: Resolver<T, H>[]) => (context: H, next?: NextFunction) => Promise<any>;

export declare const resolveExternal: <T, H extends HookContext<import("@feathersjs/feathers").Application<any, any>, any>>(...resolvers: Resolver<T, H>[]) => (context: H, next?: NextFunction) => Promise<void>;
export declare type ResolveAllSettings<H extends HookContext> = {
export type ResolveAllSettings<H extends HookContext> = {
data?: {

@@ -14,0 +14,0 @@ create: Resolver<any, H>;

@@ -61,30 +61,37 @@ "use strict";

exports.resolveData = resolveData;
const resolveResult = (...resolvers) => async (context, next) => {
var _a;
if (typeof next === 'function') {
const { $resolve: properties, ...query } = ((_a = context.params) === null || _a === void 0 ? void 0 : _a.query) || {};
const resolve = {
originalContext: context,
...context.params.resolve,
properties
};
context.params = {
...context.params,
resolve,
query
};
await next();
}
const ctx = getContext(context);
const status = context.params.resolve;
const { isPaginated, data } = getData(context);
const result = Array.isArray(data)
? await Promise.all(data.map(async (current) => runResolvers(resolvers, current, ctx, status)))
: await runResolvers(resolvers, data, ctx, status);
if (isPaginated) {
context.result.data = result;
}
else {
context.result = result;
}
const resolveResult = (...resolvers) => {
const virtualProperties = new Set(resolvers.reduce((acc, current) => acc.concat(current.virtualNames), []));
return async (context, next) => {
var _a;
if (typeof next === 'function') {
const { $resolve, $select: select, ...query } = ((_a = context.params) === null || _a === void 0 ? void 0 : _a.query) || {};
const $select = Array.isArray(select) ? select.filter((name) => !virtualProperties.has(name)) : select;
const resolve = {
originalContext: context,
...context.params.resolve,
properties: $resolve || select
};
context.params = {
...context.params,
resolve,
query: {
...query,
$select
}
};
await next();
}
const ctx = getContext(context);
const status = context.params.resolve;
const { isPaginated, data } = getData(context);
const result = Array.isArray(data)
? await Promise.all(data.map(async (current) => runResolvers(resolvers, current, ctx, status)))
: await runResolvers(resolvers, data, ctx, status);
if (isPaginated) {
context.result.data = result;
}
else {
context.result = result;
}
};
};

@@ -91,0 +98,0 @@ exports.resolveResult = resolveResult;

@@ -5,2 +5,2 @@ import { HookContext, NextFunction } from '@feathersjs/feathers';

export declare const validateQuery: <H extends HookContext<import("@feathersjs/feathers").Application<any, any>, any>>(schema: Schema<any> | Validator) => (context: H, next?: NextFunction) => Promise<any>;
export declare const validateData: <H extends HookContext<import("@feathersjs/feathers").Application<any, any>, any>>(schema: Schema<any> | DataValidatorMap) => (context: H, next?: NextFunction) => Promise<any>;
export declare const validateData: <H extends HookContext<import("@feathersjs/feathers").Application<any, any>, any>>(schema: Schema<any> | DataValidatorMap | Validator) => (context: H, next?: NextFunction) => Promise<any>;

@@ -5,2 +5,3 @@ "use strict";

const errors_1 = require("@feathersjs/errors");
const adapter_commons_1 = require("@feathersjs/adapter-commons");
const validateQuery = (schema) => {

@@ -13,2 +14,3 @@ const validator = typeof schema === 'function' ? schema : schema.validate.bind(schema);

const query = await validator(data);
Object.defineProperty(query, adapter_commons_1.VALIDATED, { value: true });
context.params = {

@@ -33,3 +35,5 @@ ...context.params,

? schema.validate.bind(schema)
: schema[context.method];
: typeof schema === 'function'
? schema
: schema[context.method];
if (validator) {

@@ -43,2 +47,3 @@ try {

}
Object.defineProperty(context.data, adapter_commons_1.VALIDATED, { value: true });
}

@@ -45,0 +50,0 @@ catch (error) {

@@ -12,6 +12,6 @@ import addFormats, { FormatName, FormatOptions, FormatsPluginOptions } from 'ajv-formats';

export * as jsonSchema from './json-schema';
export declare type Infer<S extends {
export type Infer<S extends {
_type: any;
}> = S['_type'];
export declare type Combine<S extends {
export type Combine<S extends {
_type: any;

@@ -18,0 +18,0 @@ }, U> = Pick<Infer<S>, Exclude<keyof Infer<S>, keyof U>> & U;

import { JSONSchema } from 'json-schema-to-ts';
import { JSONSchemaDefinition, Ajv, Validator } from './schema';
export declare type DataSchemaMap = {
export type DataSchemaMap = {
create: JSONSchemaDefinition;

@@ -8,3 +8,3 @@ update?: JSONSchemaDefinition;

};
export declare type DataValidatorMap = {
export type DataValidatorMap = {
create: Validator;

@@ -33,3 +33,3 @@ update: Validator;

export declare const getDataValidator: (def: JSONSchemaDefinition | DataSchemaMap, validator: Ajv) => DataValidatorMap;
export declare type PropertyQuery<D extends JSONSchema> = {
export type PropertyQuery<D extends JSONSchema> = {
anyOf: [

@@ -85,2 +85,3 @@ D,

};
export declare const SUPPORTED_TYPES: string[];
/**

@@ -103,3 +104,3 @@ * Creates Feathers a query syntax compatible JSON schema for multiple properties.

export declare const querySyntax: <T extends {
[key: string]: any;
[key: string]: import("json-schema-to-ts").JSONSchema7;
}>(definition: T) => {

@@ -123,7 +124,16 @@ readonly $limit: {

readonly type: "array";
readonly maxItems: number;
readonly items: {
readonly enum?: (keyof T)[];
readonly type: "string";
readonly enum: (keyof T)[];
};
};
readonly $or: {
readonly type: "array";
readonly items: {
readonly type: "object";
readonly additionalProperties: false;
readonly properties: { [K_1 in keyof T]: PropertyQuery<T[K_1]>; };
};
};
} & { [K_1 in keyof T]: PropertyQuery<T[K_1]>; };
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.querySyntax = exports.queryProperties = exports.queryProperty = exports.getDataValidator = exports.getValidator = void 0;
exports.querySyntax = exports.queryProperties = exports.SUPPORTED_TYPES = exports.queryProperty = exports.getDataValidator = exports.getValidator = void 0;
const commons_1 = require("@feathersjs/commons");

@@ -77,2 +77,3 @@ /**

exports.queryProperty = queryProperty;
exports.SUPPORTED_TYPES = ['string', 'number', 'integer', 'boolean', 'null'];
/**

@@ -87,2 +88,6 @@ * Creates Feathers a query syntax compatible JSON schema for multiple properties.

const definition = definitions[key];
const { type, $ref } = definition;
if ($ref || !exports.SUPPORTED_TYPES.includes(type)) {
throw new Error(`Can not create query syntax schema for property '${key}'. Only types ${exports.SUPPORTED_TYPES.join(', ')} are allowed.`);
}
result[key] = (0, exports.queryProperty)(definition);

@@ -99,32 +104,45 @@ return result;

*/
const querySyntax = (definition) => ({
$limit: {
type: 'number',
minimum: 0
},
$skip: {
type: 'number',
minimum: 0
},
$sort: {
type: 'object',
properties: Object.keys(definition).reduce((res, key) => {
const result = res;
result[key] = {
type: 'number',
enum: [1, -1]
};
return result;
}, {})
},
$select: {
type: 'array',
items: {
type: 'string',
enum: Object.keys(definition)
}
},
...(0, exports.queryProperties)(definition)
});
const querySyntax = (definition) => {
const keys = Object.keys(definition);
const props = (0, exports.queryProperties)(definition);
return {
$limit: {
type: 'number',
minimum: 0
},
$skip: {
type: 'number',
minimum: 0
},
$sort: {
type: 'object',
properties: keys.reduce((res, key) => {
const result = res;
result[key] = {
type: 'number',
enum: [1, -1]
};
return result;
}, {})
},
$select: {
type: 'array',
maxItems: keys.length,
items: {
type: 'string',
...(keys.length > 0 ? { enum: keys } : {})
}
},
$or: {
type: 'array',
items: {
type: 'object',
additionalProperties: false,
properties: props
}
},
...props
};
};
exports.querySyntax = querySyntax;
//# sourceMappingURL=json-schema.js.map
import { Schema } from './schema';
export declare type PropertyResolver<T, V, C> = (value: V | undefined, obj: T, context: C, status: ResolverStatus<T, C>) => Promise<V | undefined>;
export declare type PropertyResolverMap<T, C> = {
[key in keyof T]?: PropertyResolver<T, T[key], C>;
export type PropertyResolver<T, V, C> = ((value: V | undefined, obj: T, context: C, status: ResolverStatus<T, C>) => Promise<V | undefined>) & {
[IS_VIRTUAL]?: boolean;
};
export declare type ResolverConverter<T, C> = (obj: any, context: C, status: ResolverStatus<T, C>) => Promise<T | undefined>;
export interface ResolverConfig<T, C> {
export type VirtualResolver<T, V, C> = (obj: T, context: C, status: ResolverStatus<T, C>) => Promise<V | undefined>;
export declare const IS_VIRTUAL: unique symbol;
/**
* Create a resolver for a virtual property. A virtual property is a property that
* is computed and never has an initial value.
*
* @param virtualResolver The virtual resolver function
* @returns The property resolver function
*/
export declare const virtual: <T, V, C>(virtualResolver: VirtualResolver<T, V, C>) => PropertyResolver<T, V, C>;
export type PropertyResolverMap<T, C> = {
[key in keyof T]?: PropertyResolver<T, T[key], C> | ReturnType<typeof virtual<T, T[key], C>>;
};
export type ResolverConverter<T, C> = (obj: any, context: C, status: ResolverStatus<T, C>) => Promise<T | undefined>;
export interface ResolverOptions<T, C> {
schema?: Schema<T>;
/**
* A converter function that is run before property resolvers
* to transform the initial data into a different format.
*/
converter?: ResolverConverter<T, C>;
}
export interface ResolverConfig<T, C> extends ResolverOptions<T, C> {
/**
* @deprecated Use the `validateData` and `validateQuery` hooks explicitly instead

@@ -17,7 +36,2 @@ */

properties: PropertyResolverMap<T, C>;
/**
* A converter function that is run before property resolvers
* to transform the initial data into a different format.
*/
converter?: ResolverConverter<T, C>;
}

@@ -31,5 +45,6 @@ export interface ResolverStatus<T, C> {

export declare class Resolver<T, C> {
options: ResolverConfig<T, C>;
readonly options: ResolverConfig<T, C>;
readonly _type: T;
protected propertyNames: string[];
propertyNames: (keyof T)[];
virtualNames: (keyof T)[];
constructor(options: ResolverConfig<T, C>);

@@ -55,2 +70,3 @@ /**

*/
export declare function resolve<T, C>(properties: PropertyResolverMap<T, C>, options?: ResolverOptions<T, C>): Resolver<T, C>;
export declare function resolve<T, C>(options: ResolverConfig<T, C>): Resolver<T, C>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.resolve = exports.Resolver = void 0;
exports.resolve = exports.Resolver = exports.virtual = exports.IS_VIRTUAL = void 0;
const errors_1 = require("@feathersjs/errors");
exports.IS_VIRTUAL = Symbol('@feathersjs/schema/virtual');
/**
* Create a resolver for a virtual property. A virtual property is a property that
* is computed and never has an initial value.
*
* @param virtualResolver The virtual resolver function
* @returns The property resolver function
*/
const virtual = (virtualResolver) => {
const propertyResolver = async (_value, obj, context, status) => virtualResolver(obj, context, status);
propertyResolver[exports.IS_VIRTUAL] = true;
return propertyResolver;
};
exports.virtual = virtual;
class Resolver {

@@ -9,2 +23,3 @@ constructor(options) {

this.propertyNames = Object.keys(options.properties);
this.virtualNames = this.propertyNames.filter((name) => options.properties[name][exports.IS_VIRTUAL]);
}

@@ -85,12 +100,7 @@ /**

exports.Resolver = Resolver;
/**
* Create a new resolver with `<DataType, ContextType>`.
*
* @param options The configuration for the returned resolver
* @returns A new resolver instance
*/
function resolve(options) {
return new Resolver(options);
function resolve(properties, options) {
const settings = (properties.properties ? properties : { properties, ...options });
return new Resolver(settings);
}
exports.resolve = resolve;
//# sourceMappingURL=resolver.js.map

@@ -9,4 +9,4 @@ import Ajv, { AsyncValidateFunction, ValidateFunction } from 'ajv';

*/
export declare type Validator<T = any, R = T> = (data: T) => Promise<R>;
export declare type JSONSchemaDefinition = JSONSchema & {
export type Validator<T = any, R = T> = (data: T) => Promise<R>;
export type JSONSchemaDefinition = JSONSchema & {
$id: string;

@@ -13,0 +13,0 @@ $async?: true;

{
"name": "@feathersjs/schema",
"description": "A common data schema definition format",
"version": "5.0.0-pre.33",
"version": "5.0.0-pre.34",
"homepage": "https://feathersjs.com",

@@ -57,21 +57,22 @@ "main": "lib/",

"dependencies": {
"@feathersjs/commons": "^5.0.0-pre.33",
"@feathersjs/errors": "^5.0.0-pre.33",
"@feathersjs/feathers": "^5.0.0-pre.33",
"@feathersjs/hooks": "^0.7.5",
"@feathersjs/adapter-commons": "^5.0.0-pre.34",
"@feathersjs/commons": "^5.0.0-pre.34",
"@feathersjs/errors": "^5.0.0-pre.34",
"@feathersjs/feathers": "^5.0.0-pre.34",
"@feathersjs/hooks": "^0.7.6",
"@types/json-schema": "^7.0.11",
"ajv": "^8.11.0",
"ajv": "^8.11.2",
"ajv-formats": "^2.1.1",
"json-schema-to-ts": "^2.5.5"
"json-schema-to-ts": "^2.6.1"
},
"devDependencies": {
"@feathersjs/memory": "^5.0.0-pre.33",
"@types/mocha": "^10.0.0",
"@types/node": "^18.11.9",
"@feathersjs/memory": "^5.0.0-pre.34",
"@types/mocha": "^10.0.1",
"@types/node": "^18.11.10",
"ajv-formats": "^2.1.1",
"mocha": "^10.1.0",
"shx": "^0.3.4",
"typescript": "^4.8.4"
"typescript": "^4.9.3"
},
"gitHead": "89f516bcb1457e23a02c6212e9cd8bacc4d267d4"
"gitHead": "42cca600d00f0b3b9d89fa79be30fcd46bc50132"
}

@@ -81,11 +81,15 @@ import { HookContext, NextFunction } from '@feathersjs/feathers'

export const resolveResult =
<T, H extends HookContext>(...resolvers: Resolver<T, H>[]) =>
async (context: H, next?: NextFunction) => {
export const resolveResult = <T, H extends HookContext>(...resolvers: Resolver<T, H>[]) => {
const virtualProperties = new Set(
resolvers.reduce((acc, current) => acc.concat(current.virtualNames), [] as (keyof T)[])
)
return async (context: H, next?: NextFunction) => {
if (typeof next === 'function') {
const { $resolve: properties, ...query } = context.params?.query || {}
const { $resolve, $select: select, ...query } = context.params?.query || {}
const $select = Array.isArray(select) ? select.filter((name) => !virtualProperties.has(name)) : select
const resolve = {
originalContext: context,
...context.params.resolve,
properties
properties: $resolve || select
}

@@ -96,3 +100,6 @@

resolve,
query
query: {
...query,
$select
}
}

@@ -117,2 +124,3 @@

}
}

@@ -119,0 +127,0 @@ export const DISPATCH = Symbol('@feathersjs/schema/dispatch')

import { HookContext, NextFunction } from '@feathersjs/feathers'
import { BadRequest } from '@feathersjs/errors'
import { VALIDATED } from '@feathersjs/adapter-commons'
import { Schema, Validator } from '../schema'

@@ -15,2 +16,4 @@ import { DataValidatorMap } from '../json-schema'

Object.defineProperty(query, VALIDATED, { value: true })
context.params = {

@@ -30,3 +33,3 @@ ...context.params,

export const validateData = <H extends HookContext>(schema: Schema<any> | DataValidatorMap) => {
export const validateData = <H extends HookContext>(schema: Schema<any> | DataValidatorMap | Validator) => {
return async (context: H, next?: NextFunction) => {

@@ -37,2 +40,4 @@ const data = context.data

? (schema as Schema<any>).validate.bind(schema)
: typeof schema === 'function'
? schema
: (schema as any)[context.method]

@@ -47,2 +52,4 @@

}
Object.defineProperty(context.data, VALIDATED, { value: true })
} catch (error: any) {

@@ -49,0 +56,0 @@ throw error.ajv ? new BadRequest(error.message, error.errors) : error

@@ -125,2 +125,4 @@ import { _ } from '@feathersjs/commons'

export const SUPPORTED_TYPES = ['string', 'number', 'integer', 'boolean', 'null']
/**

@@ -136,3 +138,12 @@ * Creates Feathers a query syntax compatible JSON schema for multiple properties.

const definition = definitions[key]
const { type, $ref } = definition as any
if ($ref || !SUPPORTED_TYPES.includes(type)) {
throw new Error(
`Can not create query syntax schema for property '${key}'. Only types ${SUPPORTED_TYPES.join(
', '
)} are allowed.`
)
}
result[key] = queryProperty(definition)

@@ -150,4 +161,7 @@

*/
export const querySyntax = <T extends { [key: string]: any }>(definition: T) =>
({
export const querySyntax = <T extends { [key: string]: JSONSchema }>(definition: T) => {
const keys = Object.keys(definition)
const props = queryProperties(definition)
return {
$limit: {

@@ -163,3 +177,3 @@ type: 'number',

type: 'object',
properties: Object.keys(definition).reduce((res, key) => {
properties: keys.reduce((res, key) => {
const result = res as any

@@ -177,8 +191,18 @@

type: 'array',
maxItems: keys.length,
items: {
type: 'string',
enum: Object.keys(definition) as any as (keyof T)[]
...(keys.length > 0 ? { enum: keys as any as (keyof T)[] } : {})
}
},
...queryProperties(definition)
} as const)
$or: {
type: 'array',
items: {
type: 'object',
additionalProperties: false,
properties: props
}
},
...props
} as const
}
import { BadRequest } from '@feathersjs/errors'
import { Schema } from './schema'
export type PropertyResolver<T, V, C> = (
export type PropertyResolver<T, V, C> = ((
value: V | undefined,

@@ -9,6 +9,30 @@ obj: T,

status: ResolverStatus<T, C>
) => Promise<V | undefined>) & { [IS_VIRTUAL]?: boolean }
export type VirtualResolver<T, V, C> = (
obj: T,
context: C,
status: ResolverStatus<T, C>
) => Promise<V | undefined>
export const IS_VIRTUAL = Symbol('@feathersjs/schema/virtual')
/**
* Create a resolver for a virtual property. A virtual property is a property that
* is computed and never has an initial value.
*
* @param virtualResolver The virtual resolver function
* @returns The property resolver function
*/
export const virtual = <T, V, C>(virtualResolver: VirtualResolver<T, V, C>) => {
const propertyResolver: PropertyResolver<T, V, C> = async (_value, obj, context, status) =>
virtualResolver(obj, context, status)
propertyResolver[IS_VIRTUAL] = true
return propertyResolver
}
export type PropertyResolverMap<T, C> = {
[key in keyof T]?: PropertyResolver<T, T[key], C>
[key in keyof T]?: PropertyResolver<T, T[key], C> | ReturnType<typeof virtual<T, T[key], C>>
}

@@ -22,5 +46,13 @@

export interface ResolverConfig<T, C> {
export interface ResolverOptions<T, C> {
schema?: Schema<T>
/**
* A converter function that is run before property resolvers
* to transform the initial data into a different format.
*/
converter?: ResolverConverter<T, C>
}
export interface ResolverConfig<T, C> extends ResolverOptions<T, C> {
/**
* @deprecated Use the `validateData` and `validateQuery` hooks explicitly instead

@@ -33,7 +65,2 @@ */

properties: PropertyResolverMap<T, C>
/**
* A converter function that is run before property resolvers
* to transform the initial data into a different format.
*/
converter?: ResolverConverter<T, C>
}

@@ -50,6 +77,8 @@

readonly _type!: T
protected propertyNames: string[]
public propertyNames: (keyof T)[]
public virtualNames: (keyof T)[]
constructor(public options: ResolverConfig<T, C>) {
this.propertyNames = Object.keys(options.properties)
constructor(public readonly options: ResolverConfig<T, C>) {
this.propertyNames = Object.keys(options.properties) as any as (keyof T)[]
this.virtualNames = this.propertyNames.filter((name) => options.properties[name][IS_VIRTUAL])
}

@@ -113,3 +142,3 @@

: // By default get all data and resolver keys but remove duplicates
[...new Set(Object.keys(data).concat(this.propertyNames))]
[...new Set(Object.keys(data).concat(this.propertyNames as string[]))]
) as (keyof T)[]

@@ -163,4 +192,16 @@

*/
export function resolve<T, C>(options: ResolverConfig<T, C>) {
return new Resolver<T, C>(options)
export function resolve<T, C>(
properties: PropertyResolverMap<T, C>,
options?: ResolverOptions<T, C>
): Resolver<T, C>
export function resolve<T, C>(options: ResolverConfig<T, C>): Resolver<T, C>
export function resolve<T, C>(
properties: PropertyResolverMap<T, C> | ResolverConfig<T, C>,
options?: ResolverOptions<T, C>
) {
const settings = (
(properties as ResolverConfig<T, C>).properties ? properties : { properties, ...options }
) as ResolverConfig<T, C>
return new Resolver<T, C>(settings)
}

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