@pnp/queryable-commonjs
Advanced tools
Comparing version 3.0.0-v3nightly.20220014 to 3.0.0-v3nightly.20220017
@@ -7,3 +7,3 @@ "use strict"; | ||
return (instance) => { | ||
instance.using((0, inject_headers_js_1.InjectHeaders)({ | ||
instance.using(inject_headers_js_1.InjectHeaders({ | ||
"Authorization": `Bearer ${token}`, | ||
@@ -10,0 +10,0 @@ })); |
import { Queryable } from "../queryable.js"; | ||
import { TimelinePipe } from "@pnp/core-commonjs"; | ||
export declare function BrowserFetch(): TimelinePipe<Queryable>; | ||
export declare function BrowserFetchWithRetry(retries?: number, interval?: number): TimelinePipe<Queryable>; | ||
interface BrowserFetchProps { | ||
replace?: boolean; | ||
} | ||
export declare function BrowserFetch(props?: BrowserFetchProps): TimelinePipe<Queryable>; | ||
interface BrowserFetchWithRetryProps extends BrowserFetchProps { | ||
retries?: number; | ||
interval?: number; | ||
} | ||
export declare function BrowserFetchWithRetry(props?: BrowserFetchWithRetryProps): TimelinePipe<Queryable>; | ||
export {}; | ||
//# sourceMappingURL=browser-fetch.d.ts.map |
@@ -6,5 +6,12 @@ "use strict"; | ||
const parsers_js_1 = require("./parsers.js"); | ||
function BrowserFetch() { | ||
function BrowserFetch(props) { | ||
const { replace } = { | ||
replace: true, | ||
...props, | ||
}; | ||
return (instance) => { | ||
instance.on.send.replace(function (url, init) { | ||
if (replace) { | ||
instance.on.send.clear(); | ||
} | ||
instance.on.send(function (url, init) { | ||
this.log(`Fetch: ${init.method} ${url.toString()}`, 0); | ||
@@ -17,5 +24,14 @@ return fetch(url.toString(), init); | ||
exports.BrowserFetch = BrowserFetch; | ||
function BrowserFetchWithRetry(retries = 3, interval = 200) { | ||
function BrowserFetchWithRetry(props) { | ||
const { interval, replace, retries } = { | ||
replace: true, | ||
interval: 200, | ||
retries: 3, | ||
...props, | ||
}; | ||
return (instance) => { | ||
instance.on.send.replace(function (url, init) { | ||
if (replace) { | ||
instance.on.send.clear(); | ||
} | ||
instance.on.send(function (url, init) { | ||
let response; | ||
@@ -44,3 +60,3 @@ let wait = interval; | ||
count++; | ||
await (0, core_1.delay)(wait); | ||
await core_1.delay(wait); | ||
} | ||
@@ -47,0 +63,0 @@ try { |
@@ -22,8 +22,8 @@ "use strict"; | ||
} | ||
if (!(0, core_1.isFunc)(keyFactory)) { | ||
keyFactory = (url) => (0, core_1.getHashCode)(url.toLowerCase()).toString(); | ||
if (!core_1.isFunc(keyFactory)) { | ||
keyFactory = (url) => core_1.getHashCode(url.toLowerCase()).toString(); | ||
} | ||
const putStorage = (key, o) => { | ||
try { | ||
if ((0, core_1.isFunc)(expireFunc)) { | ||
if (core_1.isFunc(expireFunc)) { | ||
const storage = new core_1.PnPClientStorage(); | ||
@@ -45,3 +45,3 @@ const s = type === "session" ? storage.session : storage.local; | ||
try { | ||
if ((0, core_1.isFunc)(expireFunc)) { | ||
if (core_1.isFunc(expireFunc)) { | ||
const storage = new core_1.PnPClientStorage(); | ||
@@ -67,6 +67,6 @@ const s = type === "session" ? storage.session : storage.local; | ||
instance.on.init(function () { | ||
const newExecute = (0, core_1.extend)(this, { | ||
const newExecute = core_1.extend(this, { | ||
async execute(userInit = { method: "GET", headers: {} }) { | ||
setTimeout(async () => { | ||
const requestId = (0, core_1.getGUID)(); | ||
const requestId = core_1.getGUID(); | ||
const emitError = (e) => { | ||
@@ -73,0 +73,0 @@ this.log(`[id:${requestId}] Emitting error: "${e.message || e}"`, 3); |
@@ -5,3 +5,8 @@ import { Queryable } from "../queryable.js"; | ||
export declare type CacheExpireFunc = (url: string) => Date; | ||
export declare function Caching(store?: "local" | "session", keyFactory?: CacheKeyFactory, expireFunc?: CacheExpireFunc): TimelinePipe<Queryable>; | ||
export interface ICachingProps { | ||
store?: "local" | "session"; | ||
keyFactory?: CacheKeyFactory; | ||
expireFunc?: CacheExpireFunc; | ||
} | ||
export declare function Caching(props?: ICachingProps): TimelinePipe<Queryable>; | ||
//# sourceMappingURL=caching.d.ts.map |
@@ -5,11 +5,11 @@ "use strict"; | ||
const core_1 = require("@pnp/core-commonjs"); | ||
function Caching(store = "session", keyFactory, expireFunc) { | ||
function Caching(props) { | ||
const storage = new core_1.PnPClientStorage(); | ||
const { store, keyFactory, expireFunc } = { | ||
store: "local", | ||
keyFactory: (url) => core_1.getHashCode(url.toLowerCase()).toString(), | ||
expireFunc: () => core_1.dateAdd(new Date(), "minute", 5), | ||
...props, | ||
}; | ||
const s = store === "session" ? storage.session : storage.local; | ||
if (!(0, core_1.isFunc)(keyFactory)) { | ||
keyFactory = (url) => (0, core_1.getHashCode)(url.toLowerCase()).toString(); | ||
} | ||
if (!(0, core_1.isFunc)(expireFunc)) { | ||
expireFunc = () => (0, core_1.dateAdd)(new Date(), "minute", 5); | ||
} | ||
return (instance) => { | ||
@@ -16,0 +16,0 @@ instance.on.pre(async function (url, init, result) { |
@@ -31,3 +31,3 @@ "use strict"; | ||
function BufferParse() { | ||
return parseBinderWithErrorCheck(r => (0, core_2.isFunc)(r.arrayBuffer) ? r.arrayBuffer() : r.buffer()); | ||
return parseBinderWithErrorCheck(r => core_2.isFunc(r.arrayBuffer) ? r.arrayBuffer() : r.buffer()); | ||
} | ||
@@ -42,3 +42,4 @@ exports.BufferParse = BufferParse; | ||
// within observers we just throw to indicate an unrecoverable error within the pipeline | ||
throw await HttpRequestError.init(response); | ||
const y = await HttpRequestError.init(response); | ||
throw y; | ||
} | ||
@@ -50,4 +51,4 @@ return [url, response, result]; | ||
let result = json; | ||
if ((0, core_1.hOP)(json, "d")) { | ||
if ((0, core_1.hOP)(json.d, "results")) { | ||
if (core_1.hOP(json, "d")) { | ||
if (core_1.hOP(json.d, "results")) { | ||
result = json.d.results; | ||
@@ -59,3 +60,3 @@ } | ||
} | ||
else if ((0, core_1.hOP)(json, "value")) { | ||
else if (core_1.hOP(json, "value")) { | ||
result = json.value; | ||
@@ -62,0 +63,0 @@ } |
28
index.js
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const tslib_1 = require("tslib"); | ||
(0, tslib_1.__exportStar)(require("./add-prop.js"), exports); | ||
(0, tslib_1.__exportStar)(require("./invokable.js"), exports); | ||
(0, tslib_1.__exportStar)(require("./operations.js"), exports); | ||
(0, tslib_1.__exportStar)(require("./queryable.js"), exports); | ||
(0, tslib_1.__exportStar)(require("./queryable-factory.js"), exports); | ||
(0, tslib_1.__exportStar)(require("./request-builders.js"), exports); | ||
tslib_1.__exportStar(require("./add-prop.js"), exports); | ||
tslib_1.__exportStar(require("./invokable.js"), exports); | ||
tslib_1.__exportStar(require("./operations.js"), exports); | ||
tslib_1.__exportStar(require("./queryable.js"), exports); | ||
tslib_1.__exportStar(require("./queryable-factory.js"), exports); | ||
tslib_1.__exportStar(require("./request-builders.js"), exports); | ||
/** | ||
* Behavior exports | ||
*/ | ||
(0, tslib_1.__exportStar)(require("./behaviors/bearer-token.js"), exports); | ||
(0, tslib_1.__exportStar)(require("./behaviors/browser-fetch.js"), exports); | ||
(0, tslib_1.__exportStar)(require("./behaviors/caching.js"), exports); | ||
(0, tslib_1.__exportStar)(require("./behaviors/caching-pessimistic.js"), exports); | ||
(0, tslib_1.__exportStar)(require("./behaviors/inject-headers.js"), exports); | ||
(0, tslib_1.__exportStar)(require("./behaviors/parsers.js"), exports); | ||
(0, tslib_1.__exportStar)(require("./behaviors/timeout.js"), exports); | ||
(0, tslib_1.__exportStar)(require("./behaviors/resolvers.js"), exports); | ||
tslib_1.__exportStar(require("./behaviors/bearer-token.js"), exports); | ||
tslib_1.__exportStar(require("./behaviors/browser-fetch.js"), exports); | ||
tslib_1.__exportStar(require("./behaviors/caching.js"), exports); | ||
tslib_1.__exportStar(require("./behaviors/caching-pessimistic.js"), exports); | ||
tslib_1.__exportStar(require("./behaviors/inject-headers.js"), exports); | ||
tslib_1.__exportStar(require("./behaviors/parsers.js"), exports); | ||
tslib_1.__exportStar(require("./behaviors/timeout.js"), exports); | ||
tslib_1.__exportStar(require("./behaviors/resolvers.js"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -14,3 +14,3 @@ "use strict"; | ||
invokeableAction = function (init) { | ||
return (0, operations_js_1.op)(this, operations_js_1.get, init); | ||
return operations_js_1.op(this, operations_js_1.get, init); | ||
}; | ||
@@ -17,0 +17,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.op = exports.del = exports.patch = exports.put = exports.post = exports.get = void 0; | ||
const core_1 = require("@pnp/core-commonjs"); | ||
function ensureInit(method, init) { | ||
if (!(0, core_1.objectDefinedNotNull)(init)) { | ||
init = { headers: {} }; | ||
} | ||
init.method = method; | ||
return init; | ||
function ensureInit(method, init = { headers: {} }) { | ||
return { method, ...init, headers: { ...init.headers } }; | ||
} | ||
@@ -12,0 +7,0 @@ function get(init) { |
{ | ||
"name": "@pnp/queryable-commonjs", | ||
"version": "3.0.0-v3nightly.20220014", | ||
"version": "3.0.0-v3nightly.20220017", | ||
"description": "pnp - provides shared odata functionality and base classes", | ||
@@ -9,3 +9,3 @@ "main": "./index.js", | ||
"tslib": "2.3.1", | ||
"@pnp/core-commonjs": "3.0.0-v3nightly.20220014" | ||
"@pnp/core-commonjs": "3.0.0-v3nightly.20220017" | ||
}, | ||
@@ -12,0 +12,0 @@ "author": { |
@@ -8,8 +8,8 @@ "use strict"; | ||
const DefaultMoments = { | ||
pre: (0, core_1.asyncReduce)(), | ||
auth: (0, core_1.asyncReduce)(), | ||
send: (0, core_1.request)(), | ||
parse: (0, core_1.asyncReduce)(), | ||
post: (0, core_1.asyncReduce)(), | ||
data: (0, core_1.broadcast)(), | ||
pre: core_1.asyncReduce(), | ||
auth: core_1.asyncReduce(), | ||
send: core_1.request(), | ||
parse: core_1.asyncReduce(), | ||
post: core_1.asyncReduce(), | ||
data: core_1.broadcast(), | ||
}; | ||
@@ -24,5 +24,5 @@ let Queryable = class Queryable extends core_1.Timeline { | ||
if (typeof init === "string") { | ||
url = (0, core_1.combine)(init, path); | ||
url = core_1.combine(init, path); | ||
} | ||
else if ((0, core_1.isArray)(init)) { | ||
else if (core_1.isArray(init)) { | ||
if (init.length !== 2) { | ||
@@ -33,3 +33,3 @@ throw Error("When using the tuple first param only two arguments are supported"); | ||
const _url = init[1]; | ||
url = (0, core_1.combine)(_url, path); | ||
url = core_1.combine(_url, path); | ||
observers = q.observers; | ||
@@ -39,3 +39,3 @@ } | ||
const { _url, observers: _observers } = init; | ||
url = (0, core_1.combine)(_url, path); | ||
url = core_1.combine(_url, path); | ||
observers = _observers; | ||
@@ -85,3 +85,3 @@ } | ||
setTimeout(async () => { | ||
const requestId = (0, core_1.getGUID)(); | ||
const requestId = core_1.getGUID(); | ||
let requestUrl; | ||
@@ -95,3 +95,3 @@ const log = (msg, level) => { | ||
// eslint-disable-next-line prefer-const | ||
let [url, init, result] = await this.emit.pre(this.toRequestUrl(), {}, undefined); | ||
let [url, init, result] = await this.emit.pre(this.toRequestUrl(), userInit || {}, undefined); | ||
log(`Url: ${url}`, 1); | ||
@@ -139,7 +139,7 @@ if (typeof result !== "undefined") { | ||
}; | ||
Queryable = (0, tslib_1.__decorate)([ | ||
(0, core_1.extendable)(), | ||
(0, invokable_js_1.invokable)() | ||
Queryable = tslib_1.__decorate([ | ||
core_1.extendable(), | ||
invokable_js_1.invokable() | ||
], Queryable); | ||
exports.Queryable = Queryable; | ||
//# sourceMappingURL=queryable.js.map |
@@ -6,3 +6,3 @@ "use strict"; | ||
function body(o, previous) { | ||
return Object.assign({ body: (0, core_1.jsS)(o) }, previous); | ||
return Object.assign({ body: core_1.jsS(o) }, previous); | ||
} | ||
@@ -9,0 +9,0 @@ exports.body = body; |
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
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
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
75443
927
+ Added@pnp/core-commonjs@3.0.0-v3nightly.20220017(transitive)
- Removed@pnp/core-commonjs@3.0.0-v3nightly.20220014(transitive)