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

@orion-js/resolvers

Package Overview
Dependencies
Maintainers
2
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@orion-js/resolvers - npm Package Compare versions

Comparing version 3.0.14 to 3.0.15

3

lib/resolver/getExecute/getResult.js

@@ -10,8 +10,7 @@ "use strict";

const executeResolver = async () => {
const resultFunc = options.resolve;
if (parent) {
const resultFunc = options.resolve;
return await resultFunc(parent, params, viewer);
}
else {
const resultFunc = options.resolve;
return await resultFunc(params, viewer);

@@ -18,0 +17,0 @@ }

import { ResolverOptions, Execute } from '../types';
export default function (options: ResolverOptions): Execute<object, any, undefined>;
export default function (options: ResolverOptions): Execute<Function, undefined>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const index_1 = require("./index");
const helpers_1 = require("@orion-js/helpers");
it('should return a function with a resolver id', () => {

@@ -39,4 +40,4 @@ const resolver = (0, index_1.resolver)({

returns: Number,
cache: 1000,
async resolve() {
cache: 100,
async resolve(params) {
return index++;

@@ -55,2 +56,3 @@ }

expect(result5).toBe(3);
await (0, helpers_1.sleep)(100);
});

@@ -81,8 +83,12 @@ it('should create typed resolvers', async () => {

returns: Number,
resolve: async function (model) {
return model.value * 2;
resolve: async function (model, params) {
return model.value * params.times;
}
});
await resolver.resolve({ value: 1 });
await resolver.resolve({ value: 1 }, { times: 2 });
const inModel = resolver.modelResolve;
await resolver.execute({
parent: { value: 1 },
params: { times: 2 }
});
});

@@ -175,1 +181,13 @@ it('should accept a model as params', async () => {

});
it('only allow compliant resolve function', async () => {
const resolver = (0, index_1.resolver)({
resolve: async () => {
return 'hello';
}
});
const modelResolver = (0, index_1.modelResolver)({
resolve: async () => {
return 'hello';
}
});
});
import { OrionCache } from '@orion-js/cache';
export declare type GlobalResolverResolve<ParamsType = any, ReturnType = any> = (params: ParamsType, viewer: any) => Promise<ReturnType>;
export declare type ModelResolverResolve<ModelType = any, ParamsType = any, ReturnType = any> = (item: ModelType, params: ParamsType, viewer: any) => Promise<ReturnType>;
export declare type GlobalResolverResolve = (params: any, viewer: any) => Promise<any>;
export declare type ModelResolverResolve = (item: any, params: any, viewer: any) => Promise<any>;
export declare type GlobalCheckPermissions = (params: any, viewer: any) => Promise<string>;

@@ -13,8 +13,11 @@ export declare type ModelCheckPermissions = (parent: any, params: any, viewer: any) => Promise<string>;

}
export interface ExecuteParams<ParamsType = object, ModelType = undefined> {
params?: ParamsType;
declare type Parameters<T> = T extends (...args: infer P) => any ? P : never;
declare type ReturnType<T> = T extends (...args: any) => infer R ? R : any;
declare type ResolverParams<Resolve, IsModel> = IsModel extends undefined ? Parameters<Resolve>[0] : Parameters<Resolve>[1];
export interface ExecuteParams<Resolve = Function, IsModel = undefined> {
params?: ResolverParams<Resolve, IsModel>;
viewer?: any;
parent?: ModelType;
parent?: IsModel extends undefined ? undefined : Parameters<Resolve>[0];
}
export declare type Execute<ParamsType = object, ReturnType = any, ModelType = undefined> = (executeOptions: ExecuteParams<ParamsType, ModelType>) => Promise<ReturnType>;
export declare type Execute<Resolve = Function, IsModel = undefined> = (executeOptions: ExecuteParams<Resolve, IsModel>) => ReturnType<Resolve>;
export interface SharedResolverOptions {

@@ -36,9 +39,9 @@ resolverId?: string;

declare type OmitFirstArg<F> = F extends (x: any, ...args: infer P) => infer R ? (...args: P) => R : never;
export interface Resolver<Resolve = Function, ModelType = undefined> extends SharedResolverOptions {
execute: Execute;
export interface Resolver<Resolve = Function, IsModel = undefined> extends SharedResolverOptions {
execute: Execute<Resolve, IsModel>;
resolve: Resolve;
modelResolve: ModelType extends undefined ? undefined : OmitFirstArg<Resolve>;
modelResolve: IsModel extends undefined ? undefined : OmitFirstArg<Resolve>;
}
export declare type CreateResolver = <Resolve>(options: ResolverOptions<Resolve>) => Resolver<Resolve>;
export declare type CreateModelResolver = <ModelType, Resolve>(options: ResolverOptions<Resolve>) => Resolver<Resolve, ModelType>;
export declare type CreateResolver = <Resolve extends GlobalResolverResolve>(options: ResolverOptions<Resolve>) => Resolver<Resolve>;
export declare type CreateModelResolver = <Resolve extends ModelResolverResolve>(options: ResolverOptions<Resolve>) => Resolver<Resolve, true>;
export interface PermissionCheckerOptions {

@@ -45,0 +48,0 @@ resolver: ResolverOptions;

{
"name": "@orion-js/resolvers",
"version": "3.0.14",
"version": "3.0.15",
"main": "lib/index.js",

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

},
"gitHead": "265f025c5ed42f9de5f46f4ae9eae3589ec77085"
"gitHead": "e3bfc7c78cace6976985f79b733df442ef11f231"
}
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