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

@rest-hooks/endpoint

Package Overview
Dependencies
Maintainers
2
Versions
120
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rest-hooks/endpoint - npm Package Compare versions

Comparing version 3.7.2 to 3.7.3

ts4.0/AbortOptimistic.d.ts

25

package.json
{
"name": "@rest-hooks/endpoint",
"version": "3.7.2",
"version": "3.7.3",
"description": "Declarative Network Interface Definitions",

@@ -12,3 +12,3 @@ "sideEffects": false,

"typesVersions": {
">=4.0": {
">=4.2": {
"": [

@@ -21,2 +21,10 @@ "lib/index.d.ts"

},
">=4.0": {
"": [
"ts4.0/index.d.ts"
],
"*": [
"ts4.0/index.d.ts"
]
},
">=3.4": {

@@ -48,2 +56,3 @@ "": [

"lib",
"ts4.0",
"ts3.4",

@@ -58,8 +67,8 @@ "node.mjs",

"build:legacy:lib": "NODE_ENV=production BROWSERSLIST_ENV='2018' babel --root-mode upward src --out-dir legacy --extensions '.ts,.tsx,.js' --ignore '**/__tests__/**' --ignore '**/*.d.ts'",
"build:js:node": "BROWSERSLIST_ENV=node12 rollup -c",
"build:js:node": "BROWSERSLIST_ENV=node12 rollup -c && echo '{\"type\":\"commonjs\"}' > dist/package.json",
"build:js:browser": "BROWSERSLIST_ENV=legacy rollup -c",
"build:bundle": "run-s build:js:\\* && echo '{\"type\":\"commonjs\"}' > dist/package.json",
"build:clean": "rimraf lib dist legacy ts3.4 *.tsbuildinfo",
"build:bundle": "run-s build:js:\\*",
"build:clean": "rimraf lib dist legacy ts3.4 ts4.0 *.tsbuildinfo",
"build": "yarn run build:lib && yarn run build:legacy:lib && yarn run build:bundle",
"build:legacy-types": "yarn run downlevel-dts lib ts3.4 && copyfiles --up 1 ./src-legacy-types/**/*.d.ts ./ts3.4/",
"build:legacy-types": "yarn run downlevel-dts lib ts3.4 && yarn run downlevel-dts lib ts4.0 --to=4.0 && copyfiles --up 1 ./src-4.0-types/**/*.d.ts ./ts3.4/ && copyfiles --up 1 ./src-4.0-types/**/*.d.ts ./ts4.0 && copyfiles --up 1 ./src-legacy-types/**/*.d.ts ./ts3.4/",
"dev": "yarn run build:lib -w",

@@ -122,5 +131,5 @@ "prepare": "yarn run build:lib",

"rollup-plugin-terser": "^7.0.2",
"typescript": "4.9.5"
"typescript": "5.0.2"
},
"gitHead": "a1c7373956f3fd885390e13840553c920da4a62f"
"gitHead": "c0248d68395248454f494f4cb8203ed7a5cdd94a"
}

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

// had to remove all [...T], which included importing PartialArray from types
/* eslint-disable @typescript-eslint/ban-types */

@@ -61,6 +63,7 @@ import { EndpointInterface, Schema } from './interface.js';

O extends EndpointExtendOptions<F> &
Partial<Omit<E, keyof EndpointInstance<FetchFunction>>>,
Partial<Omit<E, keyof EndpointInstance<FetchFunction>>> &
Record<string, unknown>,
>(
this: E,
options: O,
options: Readonly<O>,
): ExtendedEndpoint<typeof options, E, F>;

@@ -83,7 +86,7 @@ }

*/
apply(
this: F,
thisArg: ThisParameterType<F>,
argArray?: Parameters<F>,
): ReturnType<F>;
apply<E extends FetchFunction>(
this: E,
thisArg: ThisParameterType<E>,
argArray?: Parameters<E>,
): ReturnType<E>;
/**

@@ -94,7 +97,7 @@ * Calls a method of an object, substituting another object for the current object.

*/
call(
this: F,
thisArg: ThisParameterType<F>,
...argArray: Parameters<F>
): ReturnType<F>;
call<E extends FetchFunction>(
this: E,
thisArg: ThisParameterType<E>,
...argArray: Parameters<E>
): ReturnType<E>;
/**

@@ -123,2 +126,5 @@ * For a given function, creates a bound function that has the same body as the original function.

fetch: F;
/* utilities */
/** @see https://resthooks.io/rest/api/Endpoint#testKey */
testKey(key: string): boolean;
/** The following is for compatibility with FetchShape */

@@ -130,3 +136,3 @@ /** @deprecated */

/** @deprecated */
getFetchKey(params: Parameters<F>[0]): string;
getFetchKey(...args: OnlyFirst<Parameters<F>>): string;
/** @deprecated */

@@ -165,3 +171,3 @@ options?: EndpointExtraOptions<F>;

RestFetch: F,
options?: EndpointOptions<F, S, M> & E,
options?: Readonly<EndpointOptions<F, S, M>> & E,
): EndpointInstanceInterface<F, S, M> & E;

@@ -173,1 +179,2 @@ readonly prototype: Function;

type IfTypeScriptLooseNull<Y, N> = 1 | undefined extends 1 ? Y : N;
type OnlyFirst<A extends unknown[]> = A extends [] ? [] : [A[0]];

@@ -0,8 +1,12 @@

// we just removed instances of 'abstract new'
import { UnvisitFunction } from '../interface.js';
import { AbstractInstanceType } from '../normal.js';
declare const Entity_base: import("./EntitySchema.js").IEntityClass<abstract new (...args: any[]) => {
declare const Entity_base: import('./EntitySchema.js').IEntityClass<
new (...args: any[]) => {
pk(parent?: any, key?: string | undefined): string | undefined;
}> & (abstract new (...args: any[]) => {
}
> &
(new (...args: any[]) => {
pk(parent?: any, key?: string | undefined): string | undefined;
});
});
/**

@@ -13,62 +17,91 @@ * Represents data that should be deduped by specifying a primary key.

export default abstract class Entity extends Entity_base {
/**
* A unique identifier for each Entity
*
* @param [parent] When normalizing, the object which included the entity
* @param [key] When normalizing, the key where this entity was found
*/
abstract pk(parent?: any, key?: string): string | undefined;
/** Control how automatic schema validation is handled
*
* `undefined`: Defaults - throw error in worst offense
* 'warn': only ever warn
* 'silent': Don't bother with processing at all
*
* Note: this only applies to non-nested members.
*/
protected static automaticValidation?: 'warn' | 'silent';
/** Return true to merge incoming data; false keeps existing entity
*
* @see https://resthooks.io/docs/api/schema.Entity#useIncoming
*/
static useIncoming(existingMeta: {
date: number;
fetchedAt: number;
}, incomingMeta: {
date: number;
fetchedAt: number;
}, existing: any, incoming: any): boolean;
/** Run when an existing entity is found in the store */
static mergeWithStore(existingMeta: {
date: number;
fetchedAt: number;
} | undefined, incomingMeta: {
date: number;
fetchedAt: number;
}, existing: any, incoming: any): any;
/** Factory method to convert from Plain JS Objects.
*
* @param [props] Plain Object of properties to assign.
*/
static fromJS: <T extends typeof Entity>(this: T, props?: Partial<AbstractInstanceType<T>>) => AbstractInstanceType<T>;
/**
* A unique identifier for each Entity
*
* @param [value] POJO of the entity or subset used
* @param [parent] When normalizing, the object which included the entity
* @param [key] When normalizing, the key where this entity was found
*/
static pk: <T extends typeof Entity>(this: T, value: Partial<AbstractInstanceType<T>>, parent?: any, key?: string) => string | undefined;
/** Do any transformations when first receiving input */
static process(input: any, parent: any, key: string | undefined): any;
static validate(processedEntity: any): string | undefined;
static denormalize<T extends typeof Entity>(this: T, input: any, unvisit: UnvisitFunction): [
/*denormalized*/ AbstractInstanceType<T>,
/*found*/ boolean,
/*suspend*/ boolean
];
/** Used by denormalize to set nested members */
protected static set?(entity: any, key: string, value: any): void;
/**
* A unique identifier for each Entity
*
* @param [parent] When normalizing, the object which included the entity
* @param [key] When normalizing, the key where this entity was found
*/
abstract pk(parent?: any, key?: string): string | undefined;
/** Control how automatic schema validation is handled
*
* `undefined`: Defaults - throw error in worst offense
* 'warn': only ever warn
* 'silent': Don't bother with processing at all
*
* Note: this only applies to non-nested members.
*/
protected static automaticValidation?: 'warn' | 'silent';
/** Return true to merge incoming data; false keeps existing entity
*
* @see https://resthooks.io/docs/api/schema.Entity#useIncoming
*/
static useIncoming(
existingMeta: {
date: number;
fetchedAt: number;
},
incomingMeta: {
date: number;
fetchedAt: number;
},
existing: any,
incoming: any,
): boolean;
/** Run when an existing entity is found in the store */
static mergeWithStore(
existingMeta:
| {
date: number;
fetchedAt: number;
}
| undefined,
incomingMeta: {
date: number;
fetchedAt: number;
},
existing: any,
incoming: any,
): any;
/** Factory method to convert from Plain JS Objects.
*
* @param [props] Plain Object of properties to assign.
*/
static fromJS: <T extends typeof Entity>(
this: T,
props?: Partial<AbstractInstanceType<T>>,
) => AbstractInstanceType<T>;
/**
* A unique identifier for each Entity
*
* @param [value] POJO of the entity or subset used
* @param [parent] When normalizing, the object which included the entity
* @param [key] When normalizing, the key where this entity was found
*/
static pk: <T extends typeof Entity>(
this: T,
value: Partial<AbstractInstanceType<T>>,
parent?: any,
key?: string,
) => string | undefined;
/** Do any transformations when first receiving input */
static process(input: any, parent: any, key: string | undefined): any;
static validate(processedEntity: any): string | undefined;
static denormalize<T extends typeof Entity>(
this: T,
input: any,
unvisit: UnvisitFunction,
): [
/*denormalized*/ AbstractInstanceType<T>,
/*found*/ boolean,
/*suspend*/ boolean,
];
/** Used by denormalize to set nested members */
protected static set?(entity: any, key: string, value: any): void;
}
export {};
//# sourceMappingURL=Entity.d.ts.map

@@ -0,119 +1,194 @@

// we just removed instances of 'abstract new'
import { Schema, NormalizedIndex, UnvisitFunction } from '../interface.js';
import { AbstractInstanceType } from '../normal.js';
export type Constructor = abstract new (...args: any[]) => {};
export type IDClass = abstract new (...args: any[]) => {
id: string | number | undefined;
export type Constructor = new (...args: any[]) => {};
export type IDClass = new (...args: any[]) => {
id: string | number | undefined;
};
export type PKClass = abstract new (...args: any[]) => {
pk(parent?: any, key?: string): string | undefined;
export type PKClass = new (...args: any[]) => {
pk(parent?: any, key?: string): string | undefined;
};
type ValidSchemas<TInstance> = {
[k in keyof TInstance]?: Schema;
[k in keyof TInstance]?: Schema;
};
export type EntityOptions<TInstance extends {}> = {
readonly schema?: ValidSchemas<TInstance>;
readonly pk?: ((value: TInstance, parent?: any, key?: string) => string | undefined) | keyof TInstance;
readonly key?: string;
readonly schema?: ValidSchemas<TInstance>;
readonly pk?:
| ((value: TInstance, parent?: any, key?: string) => string | undefined)
| keyof TInstance;
readonly key?: string;
} & {
readonly [K in Extract<keyof IEntityClass, 'process' | 'merge' | 'expiresAt' | 'createIfValid' | 'mergeWithStore' | 'validate' | 'shouldReorder' | 'useIncoming'>]?: IEntityClass<abstract new (...args: any[]) => TInstance>[K];
readonly [K in Extract<
keyof IEntityClass,
| 'process'
| 'merge'
| 'expiresAt'
| 'createIfValid'
| 'mergeWithStore'
| 'validate'
| 'shouldReorder'
| 'useIncoming'
>]?: IEntityClass<new (...args: any[]) => TInstance>[K];
};
export interface RequiredPKOptions<TInstance extends {}> extends EntityOptions<TInstance> {
readonly pk: ((value: TInstance, parent?: any, key?: string) => string | undefined) | keyof TInstance;
export interface RequiredPKOptions<TInstance extends {}>
extends EntityOptions<TInstance> {
readonly pk:
| ((value: TInstance, parent?: any, key?: string) => string | undefined)
| keyof TInstance;
}
export default function EntitySchema<TBase extends Constructor>(Base: TBase, options?: EntityOptions<InstanceType<TBase>>): any;
export default function EntitySchema<TBase extends Constructor>(
Base: TBase,
options?: EntityOptions<InstanceType<TBase>>,
): any;
export interface IEntityClass<TBase extends Constructor = any> {
toJSON(): {
name: string;
schema: {
[k: string]: Schema;
};
key: string;
};
/** Defines nested entities */
toJSON(): {
name: string;
schema: {
[k: string]: Schema;
[k: string]: Schema;
};
/** Returns the globally unique identifier for the static Entity */
key: string;
/** Defines indexes to enable lookup by */
indexes?: readonly string[] | undefined;
/**
* A unique identifier for each Entity
*
* @param [value] POJO of the entity or subset used
* @param [parent] When normalizing, the object which included the entity
* @param [key] When normalizing, the key where this entity was found
*/
pk<T extends (abstract new (...args: any[]) => IEntityInstance & InstanceType<TBase>) & IEntityClass & TBase>(this: T, value: Partial<AbstractInstanceType<T>>, parent?: any, key?: string): string | undefined;
/** Return true to merge incoming data; false keeps existing entity
*
* @see https://resthooks.io/docs/api/schema.Entity#useIncoming
*/
useIncoming(existingMeta: {
date: number;
fetchedAt: number;
}, incomingMeta: {
date: number;
fetchedAt: number;
}, existing: any, incoming: any): boolean;
/** Determines the order of incoming entity vs entity already in store\
*
* @see https://resthooks.io/docs/api/schema.Entity#shouldReorder
* @returns true if incoming entity should be first argument of merge()
*/
shouldReorder(existingMeta: {
date: number;
fetchedAt: number;
}, incomingMeta: {
date: number;
fetchedAt: number;
}, existing: any, incoming: any): boolean;
/** Creates new instance copying over defined values of arguments */
merge(existing: any, incoming: any): any;
/** Run when an existing entity is found in the store */
mergeWithStore(existingMeta: {
date: number;
fetchedAt: number;
}, incomingMeta: {
date: number;
fetchedAt: number;
}, existing: any, incoming: any): any;
/** Factory method to convert from Plain JS Objects.
*
* @param [props] Plain Object of properties to assign.
*/
fromJS<T extends (abstract new (...args: any[]) => IEntityInstance & InstanceType<TBase>) & IEntityClass & TBase>(this: T, props?: Partial<AbstractInstanceType<T>>): AbstractInstanceType<T>;
/** Factory method to convert from Plain JS Objects.
*
* @param [props] Plain Object of properties to assign.
*/
createIfValid<T extends (abstract new (...args: any[]) => IEntityInstance & InstanceType<TBase>) & IEntityClass & TBase>(this: T, props: Partial<AbstractInstanceType<T>>): AbstractInstanceType<T> | undefined;
/** Do any transformations when first receiving input */
process(input: any, parent: any, key: string | undefined): any;
normalize(input: any, parent: any, key: string | undefined, visit: (...args: any) => any, addEntity: (...args: any) => any, visitedEntities: Record<string, any>): any;
validate(processedEntity: any): string | undefined;
infer(args: readonly any[], indexes: NormalizedIndex, recurse: any): any;
expiresAt(meta: {
expiresAt: number;
date: number;
fetchedAt: number;
}, input: any): number;
denormalize<T extends (abstract new (...args: any[]) => IEntityInstance & InstanceType<TBase>) & IEntityClass & TBase>(this: T, input: any, unvisit: UnvisitFunction): [
/*denormalized*/ AbstractInstanceType<T>,
/*found*/ boolean,
/*suspend*/ boolean
];
/** All instance defaults set */
readonly defaults: any;
};
/** Defines nested entities */
schema: {
[k: string]: Schema;
};
/** Returns the globally unique identifier for the static Entity */
key: string;
/** Defines indexes to enable lookup by */
indexes?: readonly string[] | undefined;
/**
* A unique identifier for each Entity
*
* @param [value] POJO of the entity or subset used
* @param [parent] When normalizing, the object which included the entity
* @param [key] When normalizing, the key where this entity was found
*/
pk<
T extends (new (...args: any[]) => IEntityInstance & InstanceType<TBase>) &
IEntityClass &
TBase,
>(
this: T,
value: Partial<AbstractInstanceType<T>>,
parent?: any,
key?: string,
): string | undefined;
/** Return true to merge incoming data; false keeps existing entity
*
* @see https://resthooks.io/docs/api/schema.Entity#useIncoming
*/
useIncoming(
existingMeta: {
date: number;
fetchedAt: number;
},
incomingMeta: {
date: number;
fetchedAt: number;
},
existing: any,
incoming: any,
): boolean;
/** Determines the order of incoming entity vs entity already in store\
*
* @see https://resthooks.io/docs/api/schema.Entity#shouldReorder
* @returns true if incoming entity should be first argument of merge()
*/
shouldReorder(
existingMeta: {
date: number;
fetchedAt: number;
},
incomingMeta: {
date: number;
fetchedAt: number;
},
existing: any,
incoming: any,
): boolean;
/** Creates new instance copying over defined values of arguments */
merge(existing: any, incoming: any): any;
/** Run when an existing entity is found in the store */
mergeWithStore(
existingMeta: {
date: number;
fetchedAt: number;
},
incomingMeta: {
date: number;
fetchedAt: number;
},
existing: any,
incoming: any,
): any;
/** Factory method to convert from Plain JS Objects.
*
* @param [props] Plain Object of properties to assign.
*/
fromJS<
T extends (new (...args: any[]) => IEntityInstance & InstanceType<TBase>) &
IEntityClass &
TBase,
>(
this: T,
props?: Partial<AbstractInstanceType<T>>,
): AbstractInstanceType<T>;
/** Factory method to convert from Plain JS Objects.
*
* @param [props] Plain Object of properties to assign.
*/
createIfValid<
T extends (new (...args: any[]) => IEntityInstance & InstanceType<TBase>) &
IEntityClass &
TBase,
>(
this: T,
props: Partial<AbstractInstanceType<T>>,
): AbstractInstanceType<T> | undefined;
/** Do any transformations when first receiving input */
process(input: any, parent: any, key: string | undefined): any;
normalize(
input: any,
parent: any,
key: string | undefined,
visit: (...args: any) => any,
addEntity: (...args: any) => any,
visitedEntities: Record<string, any>,
): any;
validate(processedEntity: any): string | undefined;
infer(args: readonly any[], indexes: NormalizedIndex, recurse: any): any;
expiresAt(
meta: {
expiresAt: number;
date: number;
fetchedAt: number;
},
input: any,
): number;
denormalize<
T extends (new (...args: any[]) => IEntityInstance & InstanceType<TBase>) &
IEntityClass &
TBase,
>(
this: T,
input: any,
unvisit: UnvisitFunction,
): [
/*denormalized*/ AbstractInstanceType<T>,
/*found*/ boolean,
/*suspend*/ boolean,
];
/** All instance defaults set */
readonly defaults: any;
}
export interface IEntityInstance {
/**
* A unique identifier for each Entity
*
* @param [parent] When normalizing, the object which included the entity
* @param [key] When normalizing, the key where this entity was found
*/
pk(parent?: any, key?: string): string | undefined;
/**
* A unique identifier for each Entity
*
* @param [parent] When normalizing, the object which included the entity
* @param [key] When normalizing, the key where this entity was found
*/
pk(parent?: any, key?: string): string | undefined;
}
export {};
//# sourceMappingURL=EntitySchema.d.ts.map
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