@cerios/salesforce-sobjectly 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -12
- package/dist/cli.cjs +2 -2
- package/dist/cli.mjs +2 -2
- package/dist/{codegen-C6MEYiWo.mjs → codegen-0L2ebG9j.mjs} +202 -75
- package/dist/codegen-0L2ebG9j.mjs.map +1 -0
- package/dist/{codegen-Bylrt2Ju.cjs → codegen-Daud-Grz.cjs} +214 -71
- package/dist/codegen-Daud-Grz.cjs.map +1 -0
- package/dist/codegen.cjs +3 -1
- package/dist/codegen.d.cts +98 -31
- package/dist/codegen.d.mts +98 -31
- package/dist/codegen.mjs +3 -3
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +15 -4
- package/dist/index.d.mts +15 -4
- package/dist/index.mjs +1 -1
- package/dist/{sf-cli-_Ua-M_Zi.mjs → sf-cli-D2PgjErx.mjs} +33 -13
- package/dist/sf-cli-D2PgjErx.mjs.map +1 -0
- package/dist/{sf-cli-R6LHwqoo.cjs → sf-cli-S2BrCbik.cjs} +33 -13
- package/dist/sf-cli-S2BrCbik.cjs.map +1 -0
- package/package.json +1 -1
- package/sobjectly.config.schema.json +92 -16
- package/dist/codegen-Bylrt2Ju.cjs.map +0 -1
- package/dist/codegen-C6MEYiWo.mjs.map +0 -1
- package/dist/sf-cli-R6LHwqoo.cjs.map +0 -1
- package/dist/sf-cli-_Ua-M_Zi.mjs.map +0 -1
|
@@ -485,7 +485,7 @@ var SalesforceConnection = class {
|
|
|
485
485
|
const signal = combineSignals(request.signal, timeoutMs);
|
|
486
486
|
const prepared = this.prepare(request, method, token, attempt, signal, timeoutMs);
|
|
487
487
|
const response = await this._transport.send(prepared.transportRequest);
|
|
488
|
-
this.afterResponse(prepared.event, response
|
|
488
|
+
this.afterResponse(prepared.event, response);
|
|
489
489
|
return response;
|
|
490
490
|
}
|
|
491
491
|
prepare(request, method, token, attempt, signal, timeoutMs) {
|
|
@@ -497,6 +497,7 @@ var SalesforceConnection = class {
|
|
|
497
497
|
method,
|
|
498
498
|
url: url.toString(),
|
|
499
499
|
headers: redactHeaders(headers),
|
|
500
|
+
body,
|
|
500
501
|
attempt
|
|
501
502
|
};
|
|
502
503
|
callHook(() => this._hooks.onRequest?.(event));
|
|
@@ -515,14 +516,16 @@ var SalesforceConnection = class {
|
|
|
515
516
|
}
|
|
516
517
|
};
|
|
517
518
|
}
|
|
518
|
-
|
|
519
|
-
|
|
519
|
+
/** `body` is left out for a streamed response that hasn't been read yet. */
|
|
520
|
+
afterResponse(event, response) {
|
|
521
|
+
this.trackApiUsage(response.headers);
|
|
520
522
|
const { started, ...requestEvent } = event;
|
|
521
523
|
callHook(() => this._hooks.onResponse?.({
|
|
522
524
|
...requestEvent,
|
|
523
|
-
status,
|
|
525
|
+
status: response.status,
|
|
524
526
|
durationMs: Date.now() - started,
|
|
525
|
-
responseHeaders: headersToObject(headers)
|
|
527
|
+
responseHeaders: headersToObject(response.headers),
|
|
528
|
+
responseBody: response.body && eventBody(response.body, response.headers)
|
|
526
529
|
}));
|
|
527
530
|
}
|
|
528
531
|
toResult(request, method, response) {
|
|
@@ -557,13 +560,20 @@ var SalesforceConnection = class {
|
|
|
557
560
|
let reauthenticated = false;
|
|
558
561
|
let retries = 0;
|
|
559
562
|
for (let attempt = 1;; attempt++) {
|
|
560
|
-
const response = await this.openStream(stream, request, method, token, attempt, timeoutMs);
|
|
561
|
-
if (response.status >= 200 && response.status < 300)
|
|
563
|
+
const { event, response } = await this.openStream(stream, request, method, token, attempt, timeoutMs);
|
|
564
|
+
if (response.status >= 200 && response.status < 300) {
|
|
565
|
+
this.afterResponse(event, {
|
|
566
|
+
status: response.status,
|
|
567
|
+
headers: response.headers
|
|
568
|
+
});
|
|
569
|
+
return response;
|
|
570
|
+
}
|
|
562
571
|
const buffered = {
|
|
563
572
|
status: response.status,
|
|
564
573
|
headers: response.headers,
|
|
565
574
|
body: await collect(response.body)
|
|
566
575
|
};
|
|
576
|
+
this.afterResponse(event, buffered);
|
|
567
577
|
if (response.status === 401 && !reauthenticated && this._auth.invalidate) {
|
|
568
578
|
reauthenticated = true;
|
|
569
579
|
const next = await this.reauthenticate(token, request.signal, timeoutMs);
|
|
@@ -590,9 +600,10 @@ var SalesforceConnection = class {
|
|
|
590
600
|
const signal = request.signal ? AbortSignal.any([request.signal, headerTimeout.signal]) : headerTimeout.signal;
|
|
591
601
|
try {
|
|
592
602
|
const prepared = this.prepare(request, method, token, attempt, signal, 0);
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
603
|
+
return {
|
|
604
|
+
event: prepared.event,
|
|
605
|
+
response: await stream(prepared.transportRequest)
|
|
606
|
+
};
|
|
596
607
|
} finally {
|
|
597
608
|
clearTimeout(timer);
|
|
598
609
|
}
|
|
@@ -720,10 +731,14 @@ function toBytes(body) {
|
|
|
720
731
|
function assertSerializable(body) {
|
|
721
732
|
if (typeof Blob !== "undefined" && body instanceof Blob || typeof FormData !== "undefined" && body instanceof FormData || typeof ReadableStream !== "undefined" && body instanceof ReadableStream) throw new TypeError("Unsupported request body: Blob, FormData and streams can't be sent. Pass a Uint8Array (see buildMultipart for multipart).");
|
|
722
733
|
}
|
|
723
|
-
/**
|
|
734
|
+
/**
|
|
735
|
+
* Runs an observability hook; a throwing hook must never change the outcome of a request. A
|
|
736
|
+
* returned promise is not awaited, and its rejection is swallowed so it can't go unhandled.
|
|
737
|
+
*/
|
|
724
738
|
function callHook(hook) {
|
|
725
739
|
try {
|
|
726
|
-
hook();
|
|
740
|
+
const result = hook();
|
|
741
|
+
if (result && typeof result.catch === "function") result.catch(() => void 0);
|
|
727
742
|
} catch {}
|
|
728
743
|
}
|
|
729
744
|
function setDefault(headers, name, value) {
|
|
@@ -748,6 +763,11 @@ function parseBody(response, responseType, strict = false) {
|
|
|
748
763
|
}
|
|
749
764
|
return text;
|
|
750
765
|
}
|
|
766
|
+
/** A response body for hooks: decoded text for text content types, bytes otherwise. */
|
|
767
|
+
function eventBody(body, headers) {
|
|
768
|
+
if (body.byteLength === 0) return;
|
|
769
|
+
return isTextContentType((headers.get("content-type") ?? "").toLowerCase()) ? decoder$1.decode(body) : body;
|
|
770
|
+
}
|
|
751
771
|
function isTextContentType(contentType) {
|
|
752
772
|
return contentType === "" || contentType.includes("json") || contentType.startsWith("text/") || contentType.includes("xml") || contentType.includes("csv");
|
|
753
773
|
}
|
|
@@ -4344,4 +4364,4 @@ Object.defineProperty(exports, "tokenProvider", {
|
|
|
4344
4364
|
}
|
|
4345
4365
|
});
|
|
4346
4366
|
|
|
4347
|
-
//# sourceMappingURL=sf-cli-
|
|
4367
|
+
//# sourceMappingURL=sf-cli-S2BrCbik.cjs.map
|