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

@pnp/odata

Package Overview
Dependencies
Maintainers
9
Versions
154
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pnp/odata - npm Package Compare versions

Comparing version 2.0.2 to 2.0.3

25

batch.d.ts
import { IFetchOptions } from "@pnp/common";
import { IODataParser } from "./parsers";
export interface ODataBatchRequestInfo {
import { IQueryable } from "./queryable";
import { IRequestContext } from "./pipeline";
export interface IODataBatchRequestInfo {
url: string;

@@ -11,2 +13,3 @@ method: string;

id: string;
index: number;
}

@@ -16,4 +19,5 @@ export declare abstract class Batch {

protected _deps: Promise<void>[];
protected _reqs: ODataBatchRequestInfo[];
protected _reqs: IODataBatchRequestInfo[];
protected _rDeps: Promise<void>[];
private _index;
constructor(_batchId?: string);

@@ -24,13 +28,16 @@ get batchId(): string;

*/
protected get requests(): ODataBatchRequestInfo[];
protected get requests(): IODataBatchRequestInfo[];
/**
* Not meant for use directly
*
* @param url Request url
* @param method Request method (GET, POST, etc)
* @param options Any request options
* @param parser The parser used to handle the eventual return from the query
* @param id An identifier used to track a request within a batch
* @param batchee The IQueryable for this batch to track in order
*/
add<T>(url: string, method: string, options: IFetchOptions, parser: IODataParser<T>, id: string): Promise<T>;
track(batchee: IQueryable<any>): void;
/**
* Adds the given request context to the batch for execution
*
* @param context Details of the request to batch
*/
add<T = any>(context: IRequestContext<T>): Promise<T>;
/**
* Adds a dependency insuring that some set of actions will occur before a batch is processed.

@@ -37,0 +44,0 @@ * MUST be cleared using the returned resolve delegate to allow batches to run

@@ -9,2 +9,3 @@ import { getGUID } from "@pnp/common";

this._rDeps = [];
this._index = -1;
}

@@ -23,3 +24,4 @@ Object.defineProperty(Batch.prototype, "batchId", {

get: function () {
return this._reqs;
// we sort these each time this is accessed
return this._reqs.sort(function (info1, info2) { return info1.index - info2.index; });
},

@@ -30,19 +32,31 @@ enumerable: true,

/**
* Not meant for use directly
*
* @param url Request url
* @param method Request method (GET, POST, etc)
* @param options Any request options
* @param parser The parser used to handle the eventual return from the query
* @param id An identifier used to track a request within a batch
* @param batchee The IQueryable for this batch to track in order
*/
Batch.prototype.add = function (url, method, options, parser, id) {
Batch.prototype.track = function (batchee) {
batchee.data.batch = this;
// we need to track the order requests are added to the batch to ensure we always
// operate on them in order
if (typeof batchee.data.batchIndex === "undefined" || batchee.data.batchIndex < 0) {
batchee.data.batchIndex = ++this._index;
}
};
/**
* Adds the given request context to the batch for execution
*
* @param context Details of the request to batch
*/
Batch.prototype.add = function (context) {
var info = {
id: id,
method: method.toUpperCase(),
options: options,
parser: parser,
id: context.requestId,
index: context.batchIndex,
method: context.method.toUpperCase(),
options: context.options,
parser: context.parser,
reject: null,
resolve: null,
url: url,
url: context.url,
};
// we create a new promise that will be resolved within the batch
var p = new Promise(function (resolve, reject) {

@@ -49,0 +63,0 @@ info.resolve = resolve;

@@ -10,2 +10,3 @@ declare module "./queryable" {

__json(): <T = any>(target: T) => () => any;
__unwrap(): any;
}

@@ -17,2 +18,3 @@ interface Queryable<DefaultActionType = any> {

__json(): <T = any>(target: T) => () => any;
__unwrap(): any;
}

@@ -19,0 +21,0 @@ }

@@ -31,2 +31,4 @@ import { Logger } from "@pnp/logging";

return target.data;
case "__unwrap":
return function () { return target; };
case "__json":

@@ -33,0 +35,0 @@ return function () {

import { IQueryable } from "./queryable";
import { RequestContext } from "./pipeline";
import { IRequestContext } from "./pipeline";
export declare type IHybrid<R = any, T = any> = T & {

@@ -9,4 +9,4 @@ (this: T, ...args: any[]): Promise<R>;

export interface IInvokable<R = any> {
<T = R>(options?: Partial<RequestContext<T>>): Promise<T>;
<T = R>(options?: Partial<IRequestContext<T>>): Promise<T>;
}
//# sourceMappingURL=invokable-binder.d.ts.map

@@ -50,3 +50,3 @@ import { __read, __spread } from "tslib";

}
return Reflect.get(a[0], a[1]);
return Reflect.has(a[0], a[1]);
}, target, p);

@@ -53,0 +53,0 @@ },

{
"name": "@pnp/odata",
"version": "2.0.2",
"version": "2.0.3",
"description": "pnp - provides shared odata functionality and base classes",

@@ -9,4 +9,4 @@ "main": "./index.js",

"tslib": "1.10.0",
"@pnp/logging": "2.0.2",
"@pnp/common": "2.0.2"
"@pnp/logging": "2.0.3",
"@pnp/common": "2.0.3"
},

@@ -13,0 +13,0 @@ "author": {

@@ -15,4 +15,5 @@ import { ODataParser } from "./parsers";

return pipe(Object.assign({}, {
batch: o.batch || null,
batch: null,
batchDependency: null,
batchIndex: -1,
cachingOptions: null,

@@ -19,0 +20,0 @@ clientFactory: clientFactory,

@@ -6,3 +6,3 @@ import { IRequestClient } from "@pnp/common";

*/
export interface RequestContext<ReturnType> extends IQueryableData<ReturnType> {
export interface IRequestContext<ReturnType> extends IQueryableData<ReturnType> {
result?: ReturnType;

@@ -15,7 +15,7 @@ clientFactory: () => IRequestClient;

}
export declare type PipelineMethod<ReturnType> = (c: RequestContext<ReturnType>) => Promise<RequestContext<ReturnType>>;
export declare type PipelineMethod<ReturnType> = (c: IRequestContext<ReturnType>) => Promise<IRequestContext<ReturnType>>;
/**
* Sets the result on the context
*/
export declare function setResult<T = any>(context: RequestContext<T>, value: any): Promise<RequestContext<T>>;
export declare function setResult<T = any>(context: IRequestContext<T>, value: any): Promise<IRequestContext<T>>;
/**

@@ -26,3 +26,3 @@ * Executes the current request context's pipeline

*/
export declare function pipe<T = any>(context: RequestContext<T>): Promise<T>;
export declare function pipe<T = any>(context: IRequestContext<T>): Promise<T>;
/**

@@ -39,17 +39,17 @@ * decorator factory applied to methods in the pipeline to control behavior

*/
static logStart<T = any>(context: RequestContext<T>): Promise<RequestContext<T>>;
static logStart<T = any>(context: IRequestContext<T>): Promise<IRequestContext<T>>;
/**
* Handles caching of the request
*/
static caching<T = any>(context: RequestContext<T>): Promise<RequestContext<T>>;
static caching<T = any>(context: IRequestContext<T>): Promise<IRequestContext<T>>;
/**
* Sends the request
*/
static send<T = any>(context: RequestContext<T>): Promise<RequestContext<T>>;
static send<T = any>(context: IRequestContext<T>): Promise<IRequestContext<T>>;
/**
* Logs the end of the request
*/
static logEnd<T = any>(context: RequestContext<T>): Promise<RequestContext<T>>;
static logEnd<T = any>(context: IRequestContext<T>): Promise<IRequestContext<T>>;
}
export declare function getDefaultPipeline(): (typeof PipelineMethods.logStart)[];
//# sourceMappingURL=pipeline.d.ts.map

@@ -116,3 +116,2 @@ import { __decorate } from "tslib";

if (data !== null) {
// ensure we clear any held batch dependency we are resolving from the cache
Logger.log({

@@ -123,2 +122,3 @@ data: Logger.activeLogLevel === 1 /* Info */ ? {} : data,

});
// ensure we clear any held batch dependency we are resolving from the cache
if (isFunc(context.batchDependency)) {

@@ -149,4 +149,3 @@ context.batchDependency();

if (context.isBatched) {
// we are in a batch, so add to batch, remove dependency, and resolve with the batch's promise
var p = context.batch.add(context.url, context.method, context.options, context.parser, context.requestId);
var p = context.batch.add(context);
// we release the dependency here to ensure the batch does not execute until the request is added to the batch

@@ -153,0 +152,0 @@ if (isFunc(context.batchDependency)) {

@@ -9,2 +9,3 @@ import { IFetchOptions, IConfigOptions, IRequestClient } from "@pnp/common";

batch: Batch | null;
batchIndex: number;
batchDependency: () => void | null;

@@ -11,0 +12,0 @@ cachingOptions: ICachingOptions | null;

@@ -162,7 +162,7 @@ import { __read, __spread } from "tslib";

Queryable.prototype.inBatch = function (batch) {
if (this.batch !== null) {
if (this.hasBatch) {
throw Error("This query is already part of a batch.");
}
if (objectDefinedNotNull(batch)) {
this.data.batch = batch;
batch.track(this);
}

@@ -169,0 +169,0 @@ return this;

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