@pnp/queryable
Advanced tools
Comparing version 3.0.0-v3nightly.20211029 to 3.0.0-v3nightly.20211030
@@ -6,3 +6,3 @@ import { delay } from "@pnp/core"; | ||
instance.on.send.replace(function (url, init) { | ||
this.emit.log(`Fetch: ${init.method} ${url.toString()}`, 0); | ||
this.log(`Fetch: ${init.method} ${url.toString()}`, 0); | ||
return fetch(url.toString(), init); | ||
@@ -37,3 +37,3 @@ }); | ||
} | ||
this.emit.log(`Attempt #${count} to retry request which failed with ${response.status}: ${response.statusText}`, 0); | ||
this.log(`Attempt #${count} to retry request which failed with ${response.status}: ${response.statusText}`, 0); | ||
count++; | ||
@@ -44,3 +44,3 @@ await delay(wait); | ||
const u = url.toString(); | ||
this.emit.log(`Fetch: ${init.method} ${u}`, 0); | ||
this.log(`Fetch: ${init.method} ${u}`, 0); | ||
response = await fetch(u, init); | ||
@@ -47,0 +47,0 @@ // if we got a good response, return it, otherwise see if we can retry |
@@ -68,6 +68,5 @@ import { isFunc, getHashCode, PnPClientStorage, getGUID, extend } from "@pnp/core"; | ||
const emitError = (e) => { | ||
this.emit.log(`[id:${requestId}] Emitting error: "${e.message || e}"`, 3); | ||
this.emit[this.InternalRejectEvent](e); | ||
this.log(`[id:${requestId}] Emitting error: "${e.message || e}"`, 3); | ||
this.emit.error(e); | ||
this.emit.log(`[id:${requestId}] Emitted error: "${e.message || e}"`, 3); | ||
this.log(`[id:${requestId}] Emitted error: "${e.message || e}"`, 3); | ||
}; | ||
@@ -77,27 +76,26 @@ try { | ||
const emitSend = async () => { | ||
this.emit.log(`[id:${requestId}] Emitting auth`, 0); | ||
this.log(`[id:${requestId}] Emitting auth`, 0); | ||
[requestUrl, init] = await this.emit.auth(requestUrl, init); | ||
this.emit.log(`[id:${requestId}] Emitted auth`, 0); | ||
this.log(`[id:${requestId}] Emitted auth`, 0); | ||
// we always resepect user supplied init over observer modified init | ||
init = { ...init, ...userInit, headers: { ...init.headers, ...userInit.headers } }; | ||
this.emit.log(`[id:${requestId}] Emitting send`, 0); | ||
this.log(`[id:${requestId}] Emitting send`, 0); | ||
let response = await this.emit.send(requestUrl, init); | ||
this.emit.log(`[id:${requestId}] Emitted send`, 0); | ||
this.emit.log(`[id:${requestId}] Emitting parse`, 0); | ||
this.log(`[id:${requestId}] Emitted send`, 0); | ||
this.log(`[id:${requestId}] Emitting parse`, 0); | ||
[requestUrl, response, result] = await this.emit.parse(requestUrl, response, result); | ||
this.emit.log(`[id:${requestId}] Emitted parse`, 0); | ||
this.emit.log(`[id:${requestId}] Emitting post`, 0); | ||
this.log(`[id:${requestId}] Emitted parse`, 0); | ||
this.log(`[id:${requestId}] Emitting post`, 0); | ||
[requestUrl, result] = await this.emit.post(requestUrl, result); | ||
this.emit.log(`[id:${requestId}] Emitted post`, 0); | ||
this.log(`[id:${requestId}] Emitted post`, 0); | ||
return result; | ||
}; | ||
const emitData = () => { | ||
this.emit.log(`[id:${requestId}] Emitting data`, 0); | ||
this.emit[this.InternalResolveEvent](retVal); | ||
this.log(`[id:${requestId}] Emitting data`, 0); | ||
this.emit.data(retVal); | ||
this.emit.log(`[id:${requestId}] Emitted data`, 0); | ||
this.log(`[id:${requestId}] Emitted data`, 0); | ||
}; | ||
this.emit.log(`[id:${requestId}] Beginning request`, 1); | ||
this.log(`[id:${requestId}] Beginning request`, 1); | ||
let [requestUrl, init, result] = await this.emit.pre(this.toRequestUrl(), {}, undefined); | ||
this.emit.log(`[id:${requestId}] Url: ${requestUrl}`, 1); | ||
this.log(`[id:${requestId}] Url: ${requestUrl}`, 1); | ||
if (typeof result !== "undefined") { | ||
@@ -119,3 +117,3 @@ retVal = result; | ||
} | ||
this.emit.log(`[id:${requestId}] Returning cached results and updating cache async`, 1); | ||
this.log(`[id:${requestId}] Returning cached results and updating cache async`, 1); | ||
emitData(); | ||
@@ -125,9 +123,4 @@ } | ||
retVal = await emitSend(); | ||
// TODO:: how do we handle the case where the request pipeline has worked as expected, however | ||
// the result remains undefined? We shouldn't emit data as we don't have any, but should we have a | ||
// completed event to signal the request is completed? | ||
if (typeof retVal !== "undefined") { | ||
this.emit.log(`[id:${requestId}] Returning results`, 1); | ||
emitData(); | ||
} | ||
this.log(`[id:${requestId}] Returning results`, 1); | ||
emitData(); | ||
} | ||
@@ -139,3 +132,3 @@ } | ||
finally { | ||
this.emit.log(`[id:${requestId}] Finished request`, 1); | ||
this.log(`[id:${requestId}] Finished request`, 1); | ||
} | ||
@@ -142,0 +135,0 @@ }, 0); |
@@ -17,3 +17,3 @@ export * from "./add-prop.js"; | ||
export * from "./behaviors/timeout.js"; | ||
export * from "./behaviors/throw.js"; | ||
export * from "./behaviors/resolvers.js"; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -17,3 +17,3 @@ export * from "./add-prop.js"; | ||
export * from "./behaviors/timeout.js"; | ||
export * from "./behaviors/throw.js"; | ||
export * from "./behaviors/resolvers.js"; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@pnp/queryable", | ||
"version": "3.0.0-v3nightly.20211029", | ||
"version": "3.0.0-v3nightly.20211030", | ||
"description": "pnp - provides shared odata functionality and base classes", | ||
@@ -9,3 +9,3 @@ "main": "./index.js", | ||
"tslib": "2.1.0", | ||
"@pnp/core": "3.0.0-v3nightly.20211029" | ||
"@pnp/core": "3.0.0-v3nightly.20211030" | ||
}, | ||
@@ -12,0 +12,0 @@ "author": { |
@@ -80,53 +80,44 @@ import { __decorate } from "tslib"; | ||
let requestUrl; | ||
const log = (msg, level) => { | ||
// this allows us to easily and consistently format our messages | ||
this.log(`[${requestId}] ${msg}`, level); | ||
}; | ||
try { | ||
this.log(`[request:${requestId}] Beginning request`, 1); | ||
log("Beginning request", 1); | ||
// eslint-disable-next-line prefer-const | ||
let [url, init, result] = await this.emit.pre(this.toRequestUrl(), {}, undefined); | ||
this.log(`[request:${requestId}] Url: ${url}`, 1); | ||
log(`Url: ${url}`, 1); | ||
if (typeof result !== "undefined") { | ||
this.log(`[request:${requestId}] Result returned from pre`, 1); | ||
this.log(`[request:${requestId}] Emitting data`, 0); | ||
this.emit[this.InternalResolveEvent](result); | ||
log("Result returned from pre"); | ||
log("Emitting data"); | ||
this.emit.data(result); | ||
this.log(`[request:${requestId}] Emitted data`, 0); | ||
log("Emitted data"); | ||
return; | ||
} | ||
this.log(`[request:${requestId}] Emitting auth`, 0); | ||
log("Emitting auth"); | ||
[requestUrl, init] = await this.emit.auth(new URL(url), init); | ||
this.log(`[request:${requestId}] Emitted auth`, 0); | ||
log("Emitted auth"); | ||
// we always resepect user supplied init over observer modified init | ||
init = { ...init, ...userInit, headers: { ...init.headers, ...userInit.headers } }; | ||
this.log(`[request:${requestId}] Emitting send`, 0); | ||
log("Emitting send"); | ||
let response = await this.emit.send(requestUrl, init); | ||
this.log(`[request:${requestId}] Emitted send`, 0); | ||
this.log(`[request:${requestId}] Emitting parse`, 0); | ||
log("Emitted send"); | ||
log("Emitting parse"); | ||
[requestUrl, response, result] = await this.emit.parse(requestUrl, response, result); | ||
this.log(`[request:${requestId}] Emitted parse`, 0); | ||
this.log(`[request:${requestId}] Emitting post`, 0); | ||
log("Emitted parse"); | ||
log("Emitting post"); | ||
[requestUrl, result] = await this.emit.post(requestUrl, result); | ||
this.log(`[request:${requestId}] Emitted post`, 0); | ||
// TODO:: how do we handle the case where the request pipeline has worked as expected, however | ||
// the result remains undefined? We shouldn't emit data as we don't have any, but should we have a | ||
// completed event to signal the request is completed? | ||
if (typeof result !== "undefined") { | ||
this.log(`[request:${requestId}] Emitting data`, 0); | ||
this.emit[this.InternalResolveEvent](result); | ||
this.emit.data(result); | ||
this.log(`[request:${requestId}] Emitted data`, 0); | ||
} | ||
else { | ||
// we need to resolve the promise, perhaps this queryable doesn't return a result | ||
// but hasn't produced an error | ||
this.emit[this.InternalResolveEvent](result); | ||
} | ||
log("Emitted post"); | ||
log("Emitting data"); | ||
this.emit.data(result); | ||
log("Emitted data"); | ||
} | ||
catch (e) { | ||
this.log(`[request:${requestId}] Emitting error: "${e.message || e}"`, 3); | ||
log(`Emitting error: "${e.message || e}"`, 3); | ||
// anything that throws we emit and continue | ||
this.emit[this.InternalRejectEvent](e); | ||
this.error(e); | ||
this.log(`[request:${requestId}] Emitted error: "${e.message || e}"`, 3); | ||
log("Emitted error", 3); | ||
} | ||
finally { | ||
this.log(`[request:${requestId}] Finished request`, 1); | ||
log("Finished request", 1); | ||
} | ||
@@ -133,0 +124,0 @@ }, 0); |
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
71166
828
+ Added@pnp/core@3.0.0-v3nightly.20211030(transitive)
- Removed@pnp/core@3.0.0-v3nightly.20211029(transitive)