@commercetools/ts-client 3.1.0 → 3.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/CHANGELOG.md +12 -0
- package/dist/commercetools-ts-client.browser.cjs.js +62 -154
- package/dist/commercetools-ts-client.browser.esm.js +62 -154
- package/dist/commercetools-ts-client.cjs.dev.js +62 -154
- package/dist/commercetools-ts-client.cjs.prod.js +62 -154
- package/dist/commercetools-ts-client.esm.js +62 -154
- package/dist/commercetools-ts-client.umd.js +1 -1
- package/dist/declarations/src/middleware/auth-middleware/anonymous-session-flow.d.ts.map +1 -1
- package/dist/declarations/src/middleware/auth-middleware/client-credentials-flow.d.ts.map +1 -1
- package/dist/declarations/src/middleware/auth-middleware/password-flow.d.ts.map +1 -1
- package/dist/declarations/src/middleware/auth-middleware/refresh-token-flow.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -716,6 +716,63 @@ async function executeRequest$1(options) {
|
|
|
716
716
|
}
|
|
717
717
|
}
|
|
718
718
|
|
|
719
|
+
async function authProcessor(request, tokenFetchPromise = null, tokenCacheObject, tokenCacheKey, tokenCache, builder, options, next) {
|
|
720
|
+
// prepare request options
|
|
721
|
+
const requestOptions = {
|
|
722
|
+
request,
|
|
723
|
+
tokenCache,
|
|
724
|
+
httpClient: options.httpClient || fetch,
|
|
725
|
+
httpClientOptions: options.httpClientOptions,
|
|
726
|
+
...builder(options),
|
|
727
|
+
userOption: options,
|
|
728
|
+
next
|
|
729
|
+
};
|
|
730
|
+
|
|
731
|
+
/**
|
|
732
|
+
* check to see if the response for 401 errors
|
|
733
|
+
* @param r MiddlewareResponse
|
|
734
|
+
* @returns response
|
|
735
|
+
*/
|
|
736
|
+
const checkAndRetryUnauthorizedError = async r => {
|
|
737
|
+
let _response = Object.assign({}, r);
|
|
738
|
+
if (_response.statusCode == 401) {
|
|
739
|
+
tokenFetchPromise = executeRequest$1(requestOptions);
|
|
740
|
+
await tokenFetchPromise;
|
|
741
|
+
tokenFetchPromise = null;
|
|
742
|
+
tokenCacheObject = tokenCache.get(tokenCacheKey);
|
|
743
|
+
_response = await next(mergeAuthHeader(tokenCacheObject.token, request));
|
|
744
|
+
}
|
|
745
|
+
return _response;
|
|
746
|
+
};
|
|
747
|
+
if (request.headers && (request.headers.Authorization || request.headers.authorization)) {
|
|
748
|
+
// move on
|
|
749
|
+
return checkAndRetryUnauthorizedError(await next(request));
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
/**
|
|
753
|
+
* If there is a token in the tokenCache, and it's not
|
|
754
|
+
* expired, append the token in the `Authorization` header.
|
|
755
|
+
*/
|
|
756
|
+
tokenCacheObject = tokenCache.get(tokenCacheKey);
|
|
757
|
+
if (tokenCacheObject && tokenCacheObject.token && Date.now() < tokenCacheObject.expirationTime) {
|
|
758
|
+
return checkAndRetryUnauthorizedError(await next(mergeAuthHeader(tokenCacheObject.token, request)));
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
// If a token is already being fetched, wait for it to finish
|
|
762
|
+
if (tokenFetchPromise) {
|
|
763
|
+
await tokenFetchPromise;
|
|
764
|
+
} else {
|
|
765
|
+
// Otherwise, fetch the token and let others wait for this process to complete
|
|
766
|
+
tokenFetchPromise = executeRequest$1(requestOptions);
|
|
767
|
+
await tokenFetchPromise;
|
|
768
|
+
tokenFetchPromise = null;
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
// Now the token is present in the tokenCache and can be accessed
|
|
772
|
+
tokenCacheObject = tokenCache.get(tokenCacheKey);
|
|
773
|
+
return next(mergeAuthHeader(tokenCacheObject.token, request));
|
|
774
|
+
}
|
|
775
|
+
|
|
719
776
|
function createAuthMiddlewareForAnonymousSessionFlow$1(options) {
|
|
720
777
|
const tokenCache = options.tokenCache || store({
|
|
721
778
|
token: '',
|
|
@@ -726,46 +783,7 @@ function createAuthMiddlewareForAnonymousSessionFlow$1(options) {
|
|
|
726
783
|
const tokenCacheKey = buildTokenCacheKey(options);
|
|
727
784
|
return next => {
|
|
728
785
|
return async request => {
|
|
729
|
-
|
|
730
|
-
if (request.headers && (request.headers.Authorization || request.headers.authorization)) {
|
|
731
|
-
// move on
|
|
732
|
-
return next(request);
|
|
733
|
-
}
|
|
734
|
-
|
|
735
|
-
/**
|
|
736
|
-
* If there is a token in the tokenCache, and it's not
|
|
737
|
-
* expired, append the token in the `Authorization` header.
|
|
738
|
-
*/
|
|
739
|
-
tokenCacheObject = tokenCache.get(tokenCacheKey);
|
|
740
|
-
if (tokenCacheObject && tokenCacheObject.token && Date.now() < tokenCacheObject.expirationTime) {
|
|
741
|
-
return next(mergeAuthHeader(tokenCacheObject.token, request));
|
|
742
|
-
}
|
|
743
|
-
|
|
744
|
-
// prepare request options
|
|
745
|
-
const requestOptions = {
|
|
746
|
-
request,
|
|
747
|
-
tokenCache,
|
|
748
|
-
tokenCacheKey,
|
|
749
|
-
httpClient: options.httpClient || fetch,
|
|
750
|
-
httpClientOptions: options.httpClientOptions,
|
|
751
|
-
...buildRequestForAnonymousSessionFlow(options),
|
|
752
|
-
userOption: options,
|
|
753
|
-
next
|
|
754
|
-
};
|
|
755
|
-
|
|
756
|
-
// If a token is already being fetched, wait for it to finish
|
|
757
|
-
if (tokenFetchPromise) {
|
|
758
|
-
await tokenFetchPromise;
|
|
759
|
-
} else {
|
|
760
|
-
// Otherwise, fetch the token and let others wait for this process to complete
|
|
761
|
-
tokenFetchPromise = executeRequest$1(requestOptions);
|
|
762
|
-
await tokenFetchPromise;
|
|
763
|
-
tokenFetchPromise = null;
|
|
764
|
-
}
|
|
765
|
-
|
|
766
|
-
// Now the token is present in the tokenCache and can be accessed
|
|
767
|
-
tokenCacheObject = tokenCache.get(tokenCacheKey);
|
|
768
|
-
return next(mergeAuthHeader(tokenCacheObject.token, request));
|
|
786
|
+
return authProcessor(request, tokenFetchPromise, tokenCacheObject, tokenCacheKey, tokenCache, buildRequestForAnonymousSessionFlow, options, next);
|
|
769
787
|
};
|
|
770
788
|
};
|
|
771
789
|
}
|
|
@@ -780,46 +798,7 @@ function createAuthMiddlewareForClientCredentialsFlow$1(options) {
|
|
|
780
798
|
const tokenCacheKey = buildTokenCacheKey(options);
|
|
781
799
|
return next => {
|
|
782
800
|
return async request => {
|
|
783
|
-
|
|
784
|
-
if (request.headers && (request.headers.Authorization || request.headers.authorization)) {
|
|
785
|
-
// move on
|
|
786
|
-
return next(request);
|
|
787
|
-
}
|
|
788
|
-
|
|
789
|
-
/**
|
|
790
|
-
* If there is a token in the tokenCache, and it's not
|
|
791
|
-
* expired, append the token in the `Authorization` header.
|
|
792
|
-
*/
|
|
793
|
-
tokenCacheObject = tokenCache.get(tokenCacheKey);
|
|
794
|
-
if (tokenCacheObject && tokenCacheObject.token && Date.now() < tokenCacheObject.expirationTime) {
|
|
795
|
-
return next(mergeAuthHeader(tokenCacheObject.token, request));
|
|
796
|
-
}
|
|
797
|
-
|
|
798
|
-
// prepare request options
|
|
799
|
-
const requestOptions = {
|
|
800
|
-
request,
|
|
801
|
-
tokenCache,
|
|
802
|
-
tokenCacheKey,
|
|
803
|
-
tokenCacheObject,
|
|
804
|
-
httpClient: options.httpClient || fetch,
|
|
805
|
-
httpClientOptions: options.httpClientOptions,
|
|
806
|
-
...buildRequestForClientCredentialsFlow(options),
|
|
807
|
-
next
|
|
808
|
-
};
|
|
809
|
-
|
|
810
|
-
// If a token is already being fetched, wait for it to finish
|
|
811
|
-
if (tokenFetchPromise) {
|
|
812
|
-
await tokenFetchPromise;
|
|
813
|
-
} else {
|
|
814
|
-
// Otherwise, fetch the token and let others wait for this process to complete
|
|
815
|
-
tokenFetchPromise = executeRequest$1(requestOptions);
|
|
816
|
-
await tokenFetchPromise;
|
|
817
|
-
tokenFetchPromise = null;
|
|
818
|
-
}
|
|
819
|
-
|
|
820
|
-
// Now the token is present in the tokenCache
|
|
821
|
-
tokenCacheObject = tokenCache.get(tokenCacheKey);
|
|
822
|
-
return next(mergeAuthHeader(tokenCacheObject.token, request));
|
|
801
|
+
return authProcessor(request, tokenFetchPromise, tokenCacheObject, tokenCacheKey, tokenCache, buildRequestForClientCredentialsFlow, options, next);
|
|
823
802
|
};
|
|
824
803
|
};
|
|
825
804
|
}
|
|
@@ -860,43 +839,7 @@ function createAuthMiddlewareForPasswordFlow$1(options) {
|
|
|
860
839
|
const tokenCacheKey = buildTokenCacheKey(options);
|
|
861
840
|
return next => {
|
|
862
841
|
return async request => {
|
|
863
|
-
|
|
864
|
-
if (request.headers && (request.headers.Authorization || request.headers.authorization)) {
|
|
865
|
-
return next(request);
|
|
866
|
-
}
|
|
867
|
-
|
|
868
|
-
/**
|
|
869
|
-
* If there is a token in the tokenCache, and it's not
|
|
870
|
-
* expired, append the token in the `Authorization` header.
|
|
871
|
-
*/
|
|
872
|
-
tokenCacheObject = tokenCache.get(tokenCacheKey);
|
|
873
|
-
if (tokenCacheObject && tokenCacheObject.token && Date.now() < tokenCacheObject.expirationTime) {
|
|
874
|
-
return next(mergeAuthHeader(tokenCacheObject.token, request));
|
|
875
|
-
}
|
|
876
|
-
const requestOptions = {
|
|
877
|
-
request,
|
|
878
|
-
tokenCache,
|
|
879
|
-
tokenCacheKey,
|
|
880
|
-
httpClient: options.httpClient || fetch,
|
|
881
|
-
httpClientOptions: options.httpClientOptions,
|
|
882
|
-
...buildRequestForPasswordFlow(options),
|
|
883
|
-
userOption: options,
|
|
884
|
-
next
|
|
885
|
-
};
|
|
886
|
-
|
|
887
|
-
// If a token is already being fetched, wait for it to finish
|
|
888
|
-
if (tokenFetchPromise) {
|
|
889
|
-
await tokenFetchPromise;
|
|
890
|
-
} else {
|
|
891
|
-
// Otherwise, fetch the token and let others wait for this process to complete
|
|
892
|
-
tokenFetchPromise = executeRequest$1(requestOptions);
|
|
893
|
-
await tokenFetchPromise;
|
|
894
|
-
tokenFetchPromise = null;
|
|
895
|
-
}
|
|
896
|
-
|
|
897
|
-
// Now the token is present in the tokenCache
|
|
898
|
-
tokenCacheObject = tokenCache.get(tokenCacheKey);
|
|
899
|
-
return next(mergeAuthHeader(tokenCacheObject.token, request));
|
|
842
|
+
return authProcessor(request, tokenFetchPromise, tokenCacheObject, tokenCacheKey, tokenCache, buildRequestForPasswordFlow, options, next);
|
|
900
843
|
};
|
|
901
844
|
};
|
|
902
845
|
}
|
|
@@ -911,42 +854,7 @@ function createAuthMiddlewareForRefreshTokenFlow$1(options) {
|
|
|
911
854
|
const tokenCacheKey = buildTokenCacheKey(options);
|
|
912
855
|
return next => {
|
|
913
856
|
return async request => {
|
|
914
|
-
|
|
915
|
-
return next(request);
|
|
916
|
-
}
|
|
917
|
-
|
|
918
|
-
/**
|
|
919
|
-
* If there is a token in the tokenCache, and it's not
|
|
920
|
-
* expired, append the token in the `Authorization` header.
|
|
921
|
-
*/
|
|
922
|
-
tokenCacheObject = tokenCache.get(tokenCacheKey);
|
|
923
|
-
if (tokenCacheObject && tokenCacheObject.token && Date.now() < tokenCacheObject.expirationTime) {
|
|
924
|
-
return next(mergeAuthHeader(tokenCacheObject.token, request));
|
|
925
|
-
}
|
|
926
|
-
|
|
927
|
-
// prepare request options
|
|
928
|
-
const requestOptions = {
|
|
929
|
-
request,
|
|
930
|
-
tokenCache,
|
|
931
|
-
httpClient: options.httpClient || fetch,
|
|
932
|
-
httpClientOptions: options.httpClientOptions,
|
|
933
|
-
...buildRequestForRefreshTokenFlow(options),
|
|
934
|
-
next
|
|
935
|
-
};
|
|
936
|
-
|
|
937
|
-
// If a token is already being fetched, wait for it to finish
|
|
938
|
-
if (tokenFetchPromise) {
|
|
939
|
-
await tokenFetchPromise;
|
|
940
|
-
} else {
|
|
941
|
-
// Otherwise, fetch the token and let others wait for this process to complete
|
|
942
|
-
tokenFetchPromise = executeRequest$1(requestOptions);
|
|
943
|
-
await tokenFetchPromise;
|
|
944
|
-
tokenFetchPromise = null;
|
|
945
|
-
}
|
|
946
|
-
|
|
947
|
-
// Now the token is present in the tokenCache
|
|
948
|
-
tokenCacheObject = tokenCache.get(tokenCacheKey);
|
|
949
|
-
return next(mergeAuthHeader(tokenCacheObject.token, request));
|
|
857
|
+
return authProcessor(request, tokenFetchPromise, tokenCacheObject, tokenCacheKey, tokenCache, buildRequestForRefreshTokenFlow, options, next);
|
|
950
858
|
};
|
|
951
859
|
};
|
|
952
860
|
}
|
|
@@ -1257,7 +1165,7 @@ function createQueueMiddleware$1({
|
|
|
1257
1165
|
|
|
1258
1166
|
var packageJson = {
|
|
1259
1167
|
name: "@commercetools/ts-client",
|
|
1260
|
-
version: "3.
|
|
1168
|
+
version: "3.2.0",
|
|
1261
1169
|
engines: {
|
|
1262
1170
|
node: ">=18"
|
|
1263
1171
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var window;(window||={})["@commercetools/ts-client"]=(()=>{var ue=Object.defineProperty;var Fe=Object.getOwnPropertyDescriptor;var Ie=Object.getOwnPropertyNames;var je=Object.prototype.hasOwnProperty;var ce=(e,t)=>{for(var r in t)ue(e,r,{get:t[r],enumerable:!0})},Ne=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Ie(t))!je.call(e,i)&&i!==r&&ue(e,i,{get:()=>t[i],enumerable:!(o=Fe(t,i))||o.enumerable});return e};var Ue=e=>Ne(ue({},"__esModule",{value:!0}),e);var ft={};ce(ft,{ClientBuilder:()=>B,Process:()=>de,createAuthMiddlewareForAnonymousSessionFlow:()=>H,createAuthMiddlewareForClientCredentialsFlow:()=>v,createAuthMiddlewareForExistingTokenFlow:()=>_,createAuthMiddlewareForPasswordFlow:()=>K,createAuthMiddlewareForRefreshTokenFlow:()=>L,createClient:()=>S,createConcurrentModificationMiddleware:()=>Q,createCorrelationIdMiddleware:()=>J,createHttpMiddleware:()=>V,createLoggerMiddleware:()=>G,createQueueMiddleware:()=>Y,createUserAgentMiddleware:()=>W});var Re={};ce(Re,{createAuthMiddlewareForAnonymousSessionFlow:()=>H,createAuthMiddlewareForClientCredentialsFlow:()=>v,createAuthMiddlewareForExistingTokenFlow:()=>_,createAuthMiddlewareForPasswordFlow:()=>K,createAuthMiddlewareForRefreshTokenFlow:()=>L,createConcurrentModificationMiddleware:()=>Q,createCorrelationIdMiddleware:()=>J,createErrorMiddleware:()=>Ce,createHttpMiddleware:()=>V,createLoggerMiddleware:()=>G,createQueueMiddleware:()=>Y,createUserAgentMiddleware:()=>W});function N(e){return e&&typeof e=="string"?new TextEncoder().encode(e).length.toString():e&&e instanceof Uint8Array?e.byteLength.toString():e&&typeof e=="object"?new TextEncoder().encode(JSON.stringify(e)).length.toString():"0"}var C={};ce(C,{CONCURRENCT_REQUEST:()=>He,CTP_API_URL:()=>ve,CTP_AUTH_URL:()=>_e,DEFAULT_HEADERS:()=>he,HEADERS_CONTENT_TYPES:()=>qe});var qe=["application/json","application/graphql"],He=20,ve="https://api.europe-west1.gcp.commercetools.com",_e="https://auth.europe-west1.gcp.commercetools.com",he=["content-type","access-control-allow-origin","access-control-allow-headers","access-control-allow-methods","access-control-expose-headers","access-control-max-ag","x-correlation-id","server-timing","date","server","transfer-encoding","access-control-max-age","content-encoding","x-envoy-upstream-service-time","via","alt-svc","connection"];function T(e,t,r={}){this.code=r.code??=this.constructor.name,this.statusCode=e,this.status=e,this.message=t,Object.assign(this,r),this.name=this.constructor.name,this.constructor.prototype.__proto__=Error.prototype,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}function Ae(...e){T.call(this,0,...e)}function be(...e){T.call(this,...e)}function Ke(...e){T.call(this,400,...e)}function Le(...e){T.call(this,401,...e)}function Be(...e){T.call(this,403,...e)}function De(...e){T.call(this,404,...e)}function $e(...e){T.call(this,409,...e)}function ze(...e){T.call(this,500,...e)}function Qe(...e){T.call(this,503,...e)}function pe(e){switch(e){case 0:return Ae;case 400:return Ke;case 401:return Le;case 403:return Be;case 404:return De;case 409:return $e;case 500:return ze;case 503:return Qe;default:return}}function Je({statusCode:e,message:t,...r}){let o=t||"Unexpected non-JSON error response";e===404&&(o=`URI not found: ${r.originalRequest?.uri||r.uri}`);let i=pe(e);return i?new i(o,r):new be(e,o,r)}var U=Je;function Ve(e,t){return[503,...e].includes(t?.status||t?.statusCode)}async function Ge(e,t){async function r(){return await e({...t,headers:{...t.headers}})}return r().catch(o=>Promise.reject(o))}async function q(e){let{url:t,httpClient:r,...o}=e;return await Ge(async n=>{let{enableRetry:a,retryConfig:s,timeout:u,getAbortController:l}=o,{retryCodes:d=[],maxDelay:p=1/0,maxRetries:g=3,backoff:R=!0,retryDelay:c=200,retryOnAbort:F=!0}=s||{},w,f,m=0,I;we(d);async function O(){return r(t,{...n,...o,headers:{...o.headers},...o.body?{data:o.body}:{},withCredentials:n.credentialsMode==="include"})}function X(){let M=(l?l():null)||new AbortController;return o.abortController=M,o.signal=M.signal,M}async function j(){let M=async(ee,Se)=>{let $={};if(u){let E=X();I=setTimeout(()=>{E.abort(),E=X()},u)}try{if($=await O(),$.status>399&&Ve(ee,$))return{_response:$,shouldRetry:!0}}catch(E){if((E.name.includes("AbortError")||E.name.includes("TimeoutError"))&&Se)return{_response:E,shouldRetry:!0};throw E}finally{clearTimeout(I)}return{_response:$,shouldRetry:!1}},{_response:D,shouldRetry:Z}=await M(d,F);for(;a&&Z&&m<g;){m++,await re(te({retryCount:m,retryDelay:c,maxRetries:g,backoff:R,maxDelay:p}));let ee=await M(d,F);D=ee._response,Z=ee.shouldRetry}return D}let y=await j();try{y.text&&typeof y.text=="function"?(w=await y.text()||JSON.stringify(y[Object.getOwnPropertySymbols(y)[1]]),f=JSON.parse(w)):f=y.data||y}catch(M){throw M}return{data:f,retryCount:m,statusCode:y.status||y.statusCode||f.statusCode,headers:y.headers}},{validateStatus:n=>!0})}function oe(){return("1000000-1000-4000-8000"+-1e11).replace(/[018]/g,e=>(parseInt(e)^Math.floor(Math.random()*256)&15>>parseInt(e)/4).toString(16))}function Ye(e){return he.reduce((t,r)=>{let o=e[r]?e[r]:typeof e.get=="function"?e.get(r):null;return o&&(t[r]=o),t},{})}function x(e){if(!e)return null;if(e.raw&&typeof e.raw=="function")return e.raw();if(!e.forEach)return Ye(e);let t={};return e.forEach((r,o)=>t[o]=r),t}function z(e){return e!=null&&e.constructor!=null&&typeof e.constructor.isBuffer=="function"&&e.constructor.isBuffer(e)}function P(e){let t=JSON.parse(JSON.stringify(e));return t?.headers&&(t.headers.Authorization&&(t.headers.Authorization="Bearer ********"),t.headers.authorization&&(t.headers.authorization="Bearer ********")),t}function h(e,t){return{...t,headers:{...t.headers,Authorization:`Bearer ${e}`}}}var fe=["ACL","BIND","CHECKOUT","CONNECT","COPY","DELETE","GET","HEAD","LINK","LOCK","M-SEARCH","MERGE","MKACTIVITY","MKCALENDAR","MKCOL","MOVE","NOTIFY","OPTIONS","PATCH","POST","PROPFIND","PROPPATCH","PURGE","PUT","REBIND","REPORT","SEARCH","SOURCE","SUBSCRIBE","TRACE","UNBIND","UNLINK","UNLOCK","UNSUBSCRIBE"];function te({retryCount:e,retryDelay:t,backoff:r,maxDelay:o}){return r&&e!==0?Math.min(Math.round((Math.random()+1)*t*2**e),o):t}Math.min(Math.round((Math.random()+1)*200*2**10),1/0);function re(e){return new Promise(t=>{setTimeout(t,e)})}function A(e){if(!e?.credentials?.clientId||!e.projectKey||!e.host)throw new Error("Missing required options.");return{clientId:e.credentials.clientId,host:e.host,projectKey:e.projectKey}}function ie(e){return Date.now()+e*1e3-5*60*1e3}function b(e){let t=e;return{get:r=>t,set:(r,o)=>{t=r}}}function Te(e){return typeof e<"u"&&e!==null}function We(e){return Te(e)?typeof e=="string"?e:Object.fromEntries(Object.entries(e).filter(([t,r])=>![null,void 0,""].includes(r))):""}function Xe(e){let t={},r=new URLSearchParams(e);for(let o of r.keys())r.getAll(o).length>1?t[o]=r.getAll(o):t[o]=r.get(o);return t}function Ze(e){if(e=We(e),!e)return"";let t=new URLSearchParams(e);for(let[r,o]of Object.entries(e))Array.isArray(o)&&(t.delete(r),o.filter(Te).forEach(i=>t.append(r,i)));return t.toString()}function me(e,t=Xe){return t(e)}function ne(e,t=Ze){return t(e)}var et=()=>typeof window<"u"&&window.document&&window.document.nodeType===9;function tt(){if(et())return window.navigator.userAgent;let e=process?.version.slice(1)||"unknow",t=`(${process.platform}; ${process.arch})`;return`node.js/${e} ${t}`}function ae(e){let t=null,r=null;if(!e)throw new Error("Missing required option `name`");let o=e.version?`${e.name}/${e.version}`:e.name;e.libraryName&&!e.libraryVersion?t=e.libraryName:e.libraryName&&e.libraryVersion&&(t=`${e.libraryName}/${e.libraryVersion}`),e.contactUrl&&!e.contactEmail?r=`(+${e.contactUrl})`:!e.contactUrl&&e.contactEmail?r=`(+${e.contactEmail})`:e.contactUrl&&e.contactEmail&&(r=`(+${e.contactUrl}; +${e.contactEmail})`);let i=tt(),n=e.customAgent||"";return[o,i,t,r,n].filter(Boolean).join(" ")}function ye(e){if(!e.host)throw new Error("Request `host` or `url` is missing or invalid, please pass in a valid host e.g `host: http://a-valid-host-url`");if(!e.httpClient&&typeof e.httpClient!="function")throw new Error("An `httpClient` is not available, please pass in a `fetch` or `axios` instance as an option or have them globally available.");if(e.httpClientOptions&&Object.prototype.toString.call(e.httpClientOptions)!=="[object Object]")throw new Error("`httpClientOptions` must be an object type")}function we(e){if(!Array.isArray(e))throw new Error("`retryCodes` option must be an array of retry status (error) codes and/or messages.")}function Me(e){if(!e)throw new Error("Missing required options");if(e.middlewares&&!Array.isArray(e.middlewares))throw new Error("Middlewares should be an array");if(!e.middlewares||!Array.isArray(e.middlewares)||!e.middlewares.length)throw new Error("You need to provide at least one middleware")}function se(e,t,r={allowedMethods:fe}){if(!t)throw new Error(`The "${e}" function requires a "Request" object as an argument. See https://commercetools.github.io/nodejs/sdk/Glossary.html#clientrequest`);if(typeof t.uri!="string")throw new Error(`The "${e}" Request object requires a valid uri. See https://commercetools.github.io/nodejs/sdk/Glossary.html#clientrequest`);if(!r.allowedMethods.includes(t.method))throw new Error(`The "${e}" Request object requires a valid method. See https://commercetools.github.io/nodejs/sdk/Glossary.html#clientrequest`)}function ge(e){if(!e)throw new Error("Missing required options");if(!e.host)throw new Error("Missing required option (host)");if(!e.projectKey)throw new Error("Missing required option (projectKey)");if(!e.credentials)throw new Error("Missing required option (credentials)");let{clientId:t,clientSecret:r}=e.credentials||{};if(!(t&&r))throw new Error("Missing required credentials (clientId, clientSecret)");let o=e.scopes?e.scopes.join(" "):void 0,i=btoa(`${t}:${r}`),n=e.oauthUri||"/oauth/token",a=e.host.replace(/\/$/,"")+n,s=`grant_type=client_credentials${o?`&scope=${o}`:""}`;return{url:a,body:s,basicAuth:i}}function xe(e){if(!e)throw new Error("Missing required options");if(!e.projectKey)throw new Error("Missing required option (projectKey)");let t=e.projectKey;e.oauthUri=e.oauthUri||`/oauth/${t}/anonymous/token`;let r=ge(e);return e.credentials.anonymousId&&(r.body+=`&anonymous_id=${e.credentials.anonymousId}`),{...r}}function le(e){if(!e)throw new Error("Missing required options");if(!e.host)throw new Error("Missing required option (host)");if(!e.projectKey)throw new Error("Missing required option (projectKey)");if(!e.credentials)throw new Error("Missing required option (credentials)");if(!e.refreshToken)throw new Error("Missing required option (refreshToken)");let{clientId:t,clientSecret:r}=e.credentials;if(!(t&&r))throw new Error("Missing required credentials (clientId, clientSecret)");let o=btoa(`${t}:${r}`),i=e.oauthUri||"/oauth/token",n=e.host.replace(/\/$/,"")+i,a=`grant_type=refresh_token&refresh_token=${encodeURIComponent(e.refreshToken)}`;return{basicAuth:o,url:n,body:a}}function Oe(e){if(!e)throw new Error("Missing required options");if(!e.host)throw new Error("Missing required option (host)");if(!e.projectKey)throw new Error("Missing required option (projectKey)");if(!e.credentials)throw new Error("Missing required option (credentials)");let{clientId:t,clientSecret:r,user:o}=e.credentials,i=e.projectKey;if(!(t&&r&&o))throw new Error("Missing required credentials (clientId, clientSecret, user)");let{username:n,password:a}=o;if(!(n&&a))throw new Error("Missing required user credentials (username, password)");let s=(e.scopes||[]).join(" "),u=s?`&scope=${s}`:"",l=btoa(`${t}:${r}`),d=e.oauthUri||`/oauth/${i}/customers/token`,p=e.host.replace(/\/$/,"")+d,g=`grant_type=password&username=${encodeURIComponent(n)}&password=${encodeURIComponent(a)}${u}`;return{basicAuth:l,url:p,body:g}}async function k(e){let{httpClient:t,httpClientOptions:r,tokenCache:o,userOption:i,tokenCacheObject:n}=e,a=e.url,s=e.body,u=e.basicAuth;if(!t||typeof t!="function")throw new Error("an `httpClient` is not available, please pass in a `fetch` or `axios` instance as an option or have them globally available.");if(n&&n.refreshToken&&(!n.token||n.token&&Date.now()>n.expirationTime)){if(!i)throw new Error("Missing required options.");let d={...le({...i,refreshToken:n.refreshToken})};a=d.url,s=d.body,u=d.basicAuth}let l;try{if(l=await q({url:a,method:"POST",headers:{Authorization:`Basic ${u}`,"Content-Type":"application/x-www-form-urlencoded","Content-Length":N(s)},httpClient:t,httpClientOptions:r,body:s}),l.statusCode>=200&&l.statusCode<300){let{access_token:d,expires_in:p,refresh_token:g}=l?.data,R=ie(p);return o.set({token:d,expirationTime:R,refreshToken:g}),Promise.resolve(!0)}throw U({code:l.data.error,statusCode:l.data.statusCode,message:l.data.message,error:l.data.errors})}catch(d){throw d}}function H(e){let t=e.tokenCache||b({token:"",expirationTime:-1}),r,o=null,i=A(e);return n=>async a=>{if(a.headers&&(a.headers.Authorization||a.headers.authorization))return n(a);if(r=t.get(i),r&&r.token&&Date.now()<r.expirationTime)return n(h(r.token,a));let s={request:a,tokenCache:t,tokenCacheKey:i,httpClient:e.httpClient||fetch,httpClientOptions:e.httpClientOptions,...xe(e),userOption:e,next:n};return o?await o:(o=k(s),await o,o=null),r=t.get(i),n(h(r.token,a))}}function v(e){let t=e.tokenCache||b({token:"",expirationTime:-1}),r,o=null,i=A(e);return n=>async a=>{if(a.headers&&(a.headers.Authorization||a.headers.authorization))return n(a);if(r=t.get(i),r&&r.token&&Date.now()<r.expirationTime)return n(h(r.token,a));let s={request:a,tokenCache:t,tokenCacheKey:i,tokenCacheObject:r,httpClient:e.httpClient||fetch,httpClientOptions:e.httpClientOptions,...ge(e),next:n};return o?await o:(o=k(s),await o,o=null),r=t.get(i),n(h(r.token,a))}}function _(e,t){return r=>async o=>{if(typeof e!="string")throw new Error("authorization must be a string");let i=t?.force===void 0?!0:t.force;if(!e||o.headers&&(o.headers.Authorization||o.headers.authorization)&&i===!1)return r(o);let n={...o,headers:{...o.headers,Authorization:e}};return r(n)}}function K(e){let t=e.tokenCache||b({token:"",expirationTime:-1}),r,o=null,i=A(e);return n=>async a=>{if(a.headers&&(a.headers.Authorization||a.headers.authorization))return n(a);if(r=t.get(i),r&&r.token&&Date.now()<r.expirationTime)return n(h(r.token,a));let s={request:a,tokenCache:t,tokenCacheKey:i,httpClient:e.httpClient||fetch,httpClientOptions:e.httpClientOptions,...Oe(e),userOption:e,next:n};return o?await o:(o=k(s),await o,o=null),r=t.get(i),n(h(r.token,a))}}function L(e){let t=e.tokenCache||b({token:"",tokenCacheKey:null}),r,o=null,i=A(e);return n=>async a=>{if(a.headers&&(a.headers.Authorization||a.headers.authorization))return n(a);if(r=t.get(i),r&&r.token&&Date.now()<r.expirationTime)return n(h(r.token,a));let s={request:a,tokenCache:t,httpClient:e.httpClient||fetch,httpClientOptions:e.httpClientOptions,...le(e),next:n};return o?await o:(o=k(s),await o,o=null),r=t.get(i),n(h(r.token,a))}}function Q(e){return t=>async r=>{let o=await t(r);if(o.statusCode==409){let i=o.error.body?.errors?.[0]?.currentVersion;if(i)return e&&typeof e=="function"?r.body=await e(i,r,o):r.body=typeof r.body=="string"?{...JSON.parse(r.body),version:i}:{...r.body,version:i},t(r)}return o}}function J(e){return t=>r=>{let o={...r,headers:{...r.headers,"X-Correlation-ID":e.generate&&typeof e.generate=="function"?e.generate():oe()}};return t(o)}}function Ce(e){return t=>async r=>{let o=await t(r);if(o.error){let{error:i}=o;return{...o,statusCode:i.statusCode||0,headers:i.headers||x({}),error:{...i,body:i.data||i}}}return o}}async function rt({url:e,httpClient:t,clientOptions:r}){let{request:o,maskSensitiveHeaderData:i,includeRequestInErrorResponse:n,includeResponseHeaders:a}=r;try{let s=await q({url:e,...r,httpClient:t,method:r.method,...r.body?{body:r.body}:{}});if(a||(s.headers=null),s.statusCode>=200&&s.statusCode<300)return r.method=="HEAD"?{body:null,statusCode:s.statusCode,retryCount:s.retryCount,headers:x(s.headers)}:{body:s.data,statusCode:s.statusCode,retryCount:s.retryCount,headers:x(s.headers)};let u=U({code:s.data?.errors?.[0].code,message:s?.data?.message||s?.message,statusCode:s.statusCode||s?.data?.statusCode,method:r.method,headers:x(s.headers),body:s.data,error:s.data,retryCount:s.retryCount,...n?{originalRequest:i?P(o):o}:{uri:o.uri}});return{...u,error:u}}catch(s){let u=a?x(s.response?.headers):null,l=s.response?.status||s.response?.statusCode||s.response?.data.statusCode||0,d=s.response?.data?.message;throw{body:null,error:U({statusCode:l,code:"NetworkError",status:l,message:d||s.message,headers:u,body:s.response?.data||s,error:s.response?.data||s,...n?{originalRequest:i?P(o):o}:{uri:o.uri}})}}}function V(e){ye(e);let{host:t,credentialsMode:r,httpClient:o,timeout:i,enableRetry:n,retryConfig:a,getAbortController:s,includeOriginalRequest:u,includeRequestInErrorResponse:l=!0,includeResponseHeaders:d=!0,maskSensitiveHeaderData:p,httpClientOptions:g}=e;return R=>async c=>{let F=t.replace(/\/$/,"")+c.uri,w={...c.headers};Object.prototype.hasOwnProperty.call(w,"Content-Type")||Object.prototype.hasOwnProperty.call(w,"content-type")||(w["Content-Type"]="application/json"),w["Content-Type"]===null&&delete w["Content-Type"];let f=C.HEADERS_CONTENT_TYPES.indexOf(w["Content-Type"])>-1&&typeof c.body=="string"||z(c.body)?c.body:JSON.stringify(c.body||void 0);f&&(typeof f=="string"||z(f))&&(w["Content-Length"]=N(f));let m={enableRetry:n,retryConfig:a,request:c,method:c.method,headers:w,includeRequestInErrorResponse:l,maskSensitiveHeaderData:p,includeResponseHeaders:d,...g};r&&(m.credentialsMode=r),i&&(m.timeout=i,m.getAbortController=s),f&&(m.body=f);let I=await rt({url:F,clientOptions:m,httpClient:o}),O={...c,includeOriginalRequest:u,maskSensitiveHeaderData:p,response:I};return R(O)}}function G(e){return t=>async r=>{let o=await t(r),i=Object.assign({},o),{loggerFn:n=console.log}=e||{};return n&&typeof n=="function"&&n(o),i}}function Y({concurrency:e=20}){let t=0,r=[],o=()=>0>=e?Promise.resolve():new Promise(n=>{let a=()=>{t<e?(t++,n()):r.push(a)};a()}),i=()=>{if(t--,r.length>0){let n=r.shift();n&&n()}};return n=>a=>o().then(()=>{let s={...a,resolve(u){a.resolve(u),i()},reject(u){a.reject(u),i()}};return n(s).finally(()=>{i()})})}var ke={name:"@commercetools/ts-client",version:"3.1.0",engines:{node:">=18"},description:"commercetools Composable Commerce TypeScript SDK client.",keywords:["commercetools","composable commerce","sdk","typescript","client","middleware","http","oauth","auth"],homepage:"https://github.com/commercetools/commercetools-sdk-typescript",license:"MIT",directories:{lib:"lib",test:"test"},publishConfig:{access:"public"},repository:{type:"git",url:"git+https://github.com/commercetools/commercetools-sdk-typescript.git"},bugs:{url:"https://github.com/commercetools/commercetools-sdk-typescript/issues"},dependencies:{buffer:"^6.0.3"},files:["dist","CHANGELOG.md"],author:"Chukwuemeka Ajima <meeky.ae@gmail.com>",main:"dist/commercetools-ts-client.cjs.js",module:"dist/commercetools-ts-client.esm.js",browser:{"./dist/commercetools-ts-client.cjs.js":"./dist/commercetools-ts-client.browser.cjs.js","./dist/commercetools-ts-client.esm.js":"./dist/commercetools-ts-client.browser.esm.js"},devDependencies:{"common-tags":"1.8.2",dotenv:"16.4.7",jest:"29.7.0",nock:"14.0.1","organize-imports-cli":"0.10.0"},scripts:{organize_imports:"find src -type f -name '*.ts' | xargs organize-imports-cli",postbuild:"yarn organize_imports",post_process_generate:"yarn organize_imports",docs:"typedoc --out docs"}};function W(e){return t=>async r=>{let o=ae({...e,name:`${e.name?e.name+"/":""}commercetools-sdk-javascript-v3/${ke.version}`}),i={...r,headers:{...r.headers,"User-Agent":o}};return t(i)}}function it({middlewares:e}){return e.length===1?e[0]:e.slice().reduce((r,o)=>(...i)=>r(o.apply(null,i)))}var Ee;function de(e,t,r){if(se("process",e,{allowedMethods:["GET"]}),typeof t!="function")throw new Error('The "process" function accepts a "Function" as a second argument that returns a Promise. See https://commercetools.github.io/nodejs/sdk/api/sdkClient.html#processrequest-processfn-options');let o={total:Number.POSITIVE_INFINITY,accumulate:!0,...r};return new Promise((i,n)=>{let a,s="";if(e&&e.uri){let[R,c]=e.uri.split("?");a=R,s=c}let l={limit:20,...{...me(s)}},d=o.total,p=!1,g=async(R,c=[])=>{let F=l.limit<d?l.limit:d,w=ne({...l,limit:F}),f={sort:"id asc",withTotal:!1,...R?{where:`id > "${R}"`}:{}},m=ne(f),I={...e,uri:`${a}?${m}&${w}`};try{let O=await S(Ee).execute(I),{results:X,count:j}=O?.body||{};if(!j&&p)return i(c||[]);let y=await Promise.resolve(t(O)),M;if(p=!0,o.accumulate&&(M=c.concat(y||[])),d-=j,j<l.limit||!d)return i(M||[]);let D=X[j-1],Z=D&&D.id;g(Z,M)}catch(O){n(O)}};g()})}function S(e){Ee=e,Me(e);let t=!1,r={async resolve(i){let{response:n,includeOriginalRequest:a,maskSensitiveHeaderData:s,...u}=i,{retryCount:l,...d}=n;return t=s,{body:null,error:null,reject:i.reject,resolve:i.resolve,...d,...a?{originalRequest:u}:{},...n?.retryCount?{retryCount:n.retryCount}:{}}}},o=it(e)(r.resolve);return{process:de,execute(i){return se("exec",i),new Promise(async(n,a)=>{try{let s=await o({reject:a,resolve:n,...i});if(s.error)return a(s.error);s.originalRequest&&t&&(s.originalRequest=P(s.originalRequest)),n(s)}catch(s){a(s)}})}}}var{createAuthMiddlewareForPasswordFlow:nt,createAuthMiddlewareForAnonymousSessionFlow:at,createAuthMiddlewareForClientCredentialsFlow:st,createAuthMiddlewareForRefreshTokenFlow:lt,createAuthMiddlewareForExistingTokenFlow:dt,createCorrelationIdMiddleware:ut,createHttpMiddleware:ct,createLoggerMiddleware:ht,createQueueMiddleware:pt,createUserAgentMiddleware:Pe,createConcurrentModificationMiddleware:wt}=Re,B=class{projectKey;authMiddleware;httpMiddleware;userAgentMiddleware;correlationIdMiddleware;loggerMiddleware;queueMiddleware;concurrentMiddleware;telemetryMiddleware;beforeMiddleware;afterMiddleware;middlewares=[];constructor(){this.userAgentMiddleware=Pe({})}withProjectKey(t){return this.projectKey=t,this}defaultClient(t,r,o,i,n,a){return this.withClientCredentialsFlow({host:o,projectKey:i||this.projectKey,credentials:r,httpClient:a||fetch,scopes:n}).withHttpMiddleware({host:t,httpClient:a||fetch})}withAuthMiddleware(t){return this.authMiddleware=t,this}withMiddleware(t){return this.middlewares.push(t),this}withClientCredentialsFlow(t){return this.withAuthMiddleware(st({host:t.host||C.CTP_AUTH_URL,projectKey:t.projectKey||this.projectKey,credentials:{clientId:t.credentials.clientId||null,clientSecret:t.credentials.clientSecret||null},oauthUri:t.oauthUri||null,scopes:t.scopes,httpClient:t.httpClient||fetch,...t}))}withPasswordFlow(t){return this.withAuthMiddleware(nt({host:t.host||C.CTP_AUTH_URL,projectKey:t.projectKey||this.projectKey,credentials:{clientId:t.credentials.clientId||null,clientSecret:t.credentials.clientSecret||null,user:{username:t.credentials.user.username||null,password:t.credentials.user.password||null}},httpClient:t.httpClient||fetch,...t}))}withAnonymousSessionFlow(t){return this.withAuthMiddleware(at({host:t.host||C.CTP_AUTH_URL,projectKey:this.projectKey||t.projectKey,credentials:{clientId:t.credentials.clientId||null,clientSecret:t.credentials.clientSecret||null,anonymousId:t.credentials.anonymousId||null},httpClient:t.httpClient||fetch,...t}))}withRefreshTokenFlow(t){return this.withAuthMiddleware(lt({host:t.host||C.CTP_AUTH_URL,projectKey:this.projectKey||t.projectKey,credentials:{clientId:t.credentials.clientId||null,clientSecret:t.credentials.clientSecret||null},httpClient:t.httpClient||fetch,refreshToken:t.refreshToken||null,...t}))}withExistingTokenFlow(t,r){return this.withAuthMiddleware(dt(t,{force:r.force||!0,...r}))}withHttpMiddleware(t){return this.httpMiddleware=ct({host:t.host||C.CTP_API_URL,httpClient:t.httpClient||fetch,...t}),this}withUserAgentMiddleware(t){return this.userAgentMiddleware=Pe(t),this}withQueueMiddleware(t){return this.queueMiddleware=pt({concurrency:t.concurrency||C.CONCURRENCT_REQUEST,...t}),this}withLoggerMiddleware(t){return this.loggerMiddleware=ht(t),this}withCorrelationIdMiddleware(t){return this.correlationIdMiddleware=ut({generate:t?.generate,...t}),this}withConcurrentModificationMiddleware(t){return this.concurrentMiddleware=wt(t?.concurrentModificationHandlerFn),this}withTelemetryMiddleware(t){let{createTelemetryMiddleware:r,...o}=t;return this.withUserAgentMiddleware({customAgent:o?.userAgent||"typescript-sdk-apm-middleware"}),this.telemetryMiddleware=r(o),this}withBeforeExecutionMiddleware(t){let{middleware:r,...o}=t||{};return this.beforeMiddleware=t.middleware(o),this}withAfterExecutionMiddleware(t){let{middleware:r,...o}=t||{};return this.afterMiddleware=t.middleware(o),this}build(){let t=this.middlewares.slice();return this.telemetryMiddleware&&t.push(this.telemetryMiddleware),this.correlationIdMiddleware&&t.push(this.correlationIdMiddleware),this.userAgentMiddleware&&t.push(this.userAgentMiddleware),this.authMiddleware&&t.push(this.authMiddleware),this.beforeMiddleware&&t.push(this.beforeMiddleware),this.queueMiddleware&&t.push(this.queueMiddleware),this.loggerMiddleware&&t.push(this.loggerMiddleware),this.concurrentMiddleware&&t.push(this.concurrentMiddleware),this.httpMiddleware&&t.push(this.httpMiddleware),this.afterMiddleware&&t.push(this.afterMiddleware),S({middlewares:t})}};return Ue(ft);})();
|
|
1
|
+
var window;(window||={})["@commercetools/ts-client"]=(()=>{var ue=Object.defineProperty;var Fe=Object.getOwnPropertyDescriptor;var Ie=Object.getOwnPropertyNames;var Ne=Object.prototype.hasOwnProperty;var ce=(e,t)=>{for(var r in t)ue(e,r,{get:t[r],enumerable:!0})},Ue=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Ie(t))!Ne.call(e,i)&&i!==r&&ue(e,i,{get:()=>t[i],enumerable:!(o=Fe(t,i))||o.enumerable});return e};var je=e=>Ue(ue({},"__esModule",{value:!0}),e);var mt={};ce(mt,{ClientBuilder:()=>L,Process:()=>de,createAuthMiddlewareForAnonymousSessionFlow:()=>v,createAuthMiddlewareForClientCredentialsFlow:()=>H,createAuthMiddlewareForExistingTokenFlow:()=>_,createAuthMiddlewareForPasswordFlow:()=>B,createAuthMiddlewareForRefreshTokenFlow:()=>K,createClient:()=>P,createConcurrentModificationMiddleware:()=>z,createCorrelationIdMiddleware:()=>J,createHttpMiddleware:()=>V,createLoggerMiddleware:()=>G,createQueueMiddleware:()=>Y,createUserAgentMiddleware:()=>W});var Ae={};ce(Ae,{createAuthMiddlewareForAnonymousSessionFlow:()=>v,createAuthMiddlewareForClientCredentialsFlow:()=>H,createAuthMiddlewareForExistingTokenFlow:()=>_,createAuthMiddlewareForPasswordFlow:()=>B,createAuthMiddlewareForRefreshTokenFlow:()=>K,createConcurrentModificationMiddleware:()=>z,createCorrelationIdMiddleware:()=>J,createErrorMiddleware:()=>Re,createHttpMiddleware:()=>V,createLoggerMiddleware:()=>G,createQueueMiddleware:()=>Y,createUserAgentMiddleware:()=>W});function I(e){return e&&typeof e=="string"?new TextEncoder().encode(e).length.toString():e&&e instanceof Uint8Array?e.byteLength.toString():e&&typeof e=="object"?new TextEncoder().encode(JSON.stringify(e)).length.toString():"0"}var g={};ce(g,{CONCURRENCT_REQUEST:()=>He,CTP_API_URL:()=>_e,CTP_AUTH_URL:()=>Be,DEFAULT_HEADERS:()=>pe,HEADERS_CONTENT_TYPES:()=>ve});var ve=["application/json","application/graphql"],He=20,_e="https://api.europe-west1.gcp.commercetools.com",Be="https://auth.europe-west1.gcp.commercetools.com",pe=["content-type","access-control-allow-origin","access-control-allow-headers","access-control-allow-methods","access-control-expose-headers","access-control-max-ag","x-correlation-id","server-timing","date","server","transfer-encoding","access-control-max-age","content-encoding","x-envoy-upstream-service-time","via","alt-svc","connection"];function b(e,t,r={}){this.code=r.code??=this.constructor.name,this.statusCode=e,this.status=e,this.message=t,Object.assign(this,r),this.name=this.constructor.name,this.constructor.prototype.__proto__=Error.prototype,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}function be(...e){b.call(this,0,...e)}function Te(...e){b.call(this,...e)}function Ke(...e){b.call(this,400,...e)}function Le(...e){b.call(this,401,...e)}function $e(...e){b.call(this,403,...e)}function De(...e){b.call(this,404,...e)}function Qe(...e){b.call(this,409,...e)}function ze(...e){b.call(this,500,...e)}function Je(...e){b.call(this,503,...e)}function he(e){switch(e){case 0:return be;case 400:return Ke;case 401:return Le;case 403:return $e;case 404:return De;case 409:return Qe;case 500:return ze;case 503:return Je;default:return}}function Ve({statusCode:e,message:t,...r}){let o=t||"Unexpected non-JSON error response";e===404&&(o=`URI not found: ${r.originalRequest?.uri||r.uri}`);let i=he(e);return i?new i(o,r):new Te(e,o,r)}var N=Ve;function Ge(e,t){return[503,...e].includes(t?.status||t?.statusCode)}async function Ye(e,t){async function r(){return await e({...t,headers:{...t.headers}})}return r().catch(o=>Promise.reject(o))}async function U(e){let{url:t,httpClient:r,...o}=e;return await Ye(async s=>{let{enableRetry:a,retryConfig:n,timeout:u,getAbortController:l}=o,{retryCodes:d=[],maxDelay:c=1/0,maxRetries:M=3,backoff:C=!0,retryDelay:p=200,retryOnAbort:S=!0}=n||{},h,w,f=0,q;we(d);async function x(){return r(t,{...s,...o,headers:{...o.headers},...o.body?{data:o.body}:{},withCredentials:s.credentialsMode==="include"})}function X(){let y=(l?l():null)||new AbortController;return o.abortController=y,o.signal=y.signal,y}async function F(){let y=async(ee,qe)=>{let D={};if(u){let O=X();q=setTimeout(()=>{O.abort(),O=X()},u)}try{if(D=await x(),D.status>399&&Ge(ee,D))return{_response:D,shouldRetry:!0}}catch(O){if((O.name.includes("AbortError")||O.name.includes("TimeoutError"))&&qe)return{_response:O,shouldRetry:!0};throw O}finally{clearTimeout(q)}return{_response:D,shouldRetry:!1}},{_response:$,shouldRetry:Z}=await y(d,S);for(;a&&Z&&f<M;){f++,await re(te({retryCount:f,retryDelay:p,maxRetries:M,backoff:C,maxDelay:c}));let ee=await y(d,S);$=ee._response,Z=ee.shouldRetry}return $}let m=await F();try{m.text&&typeof m.text=="function"?(h=await m.text()||JSON.stringify(m[Object.getOwnPropertySymbols(m)[1]]),w=JSON.parse(h)):w=m.data||m}catch(y){throw y}return{data:w,retryCount:f,statusCode:m.status||m.statusCode||w.statusCode,headers:m.headers}},{validateStatus:s=>!0})}function oe(){return("1000000-1000-4000-8000"+-1e11).replace(/[018]/g,e=>(parseInt(e)^Math.floor(Math.random()*256)&15>>parseInt(e)/4).toString(16))}function We(e){return pe.reduce((t,r)=>{let o=e[r]?e[r]:typeof e.get=="function"?e.get(r):null;return o&&(t[r]=o),t},{})}function T(e){if(!e)return null;if(e.raw&&typeof e.raw=="function")return e.raw();if(!e.forEach)return We(e);let t={};return e.forEach((r,o)=>t[o]=r),t}function Q(e){return e!=null&&e.constructor!=null&&typeof e.constructor.isBuffer=="function"&&e.constructor.isBuffer(e)}function k(e){let t=JSON.parse(JSON.stringify(e));return t?.headers&&(t.headers.Authorization&&(t.headers.Authorization="Bearer ********"),t.headers.authorization&&(t.headers.authorization="Bearer ********")),t}function j(e,t){return{...t,headers:{...t.headers,Authorization:`Bearer ${e}`}}}var fe=["ACL","BIND","CHECKOUT","CONNECT","COPY","DELETE","GET","HEAD","LINK","LOCK","M-SEARCH","MERGE","MKACTIVITY","MKCALENDAR","MKCOL","MOVE","NOTIFY","OPTIONS","PATCH","POST","PROPFIND","PROPPATCH","PURGE","PUT","REBIND","REPORT","SEARCH","SOURCE","SUBSCRIBE","TRACE","UNBIND","UNLINK","UNLOCK","UNSUBSCRIBE"];function te({retryCount:e,retryDelay:t,backoff:r,maxDelay:o}){return r&&e!==0?Math.min(Math.round((Math.random()+1)*t*2**e),o):t}Math.min(Math.round((Math.random()+1)*200*2**10),1/0);function re(e){return new Promise(t=>{setTimeout(t,e)})}function R(e){if(!e?.credentials?.clientId||!e.projectKey||!e.host)throw new Error("Missing required options.");return{clientId:e.credentials.clientId,host:e.host,projectKey:e.projectKey}}function ie(e){return Date.now()+e*1e3-5*60*1e3}function A(e){let t=e;return{get:r=>t,set:(r,o)=>{t=r}}}function xe(e){return typeof e<"u"&&e!==null}function Xe(e){return xe(e)?typeof e=="string"?e:Object.fromEntries(Object.entries(e).filter(([t,r])=>![null,void 0,""].includes(r))):""}function Ze(e){let t={},r=new URLSearchParams(e);for(let o of r.keys())r.getAll(o).length>1?t[o]=r.getAll(o):t[o]=r.get(o);return t}function et(e){if(e=Xe(e),!e)return"";let t=new URLSearchParams(e);for(let[r,o]of Object.entries(e))Array.isArray(o)&&(t.delete(r),o.filter(xe).forEach(i=>t.append(r,i)));return t.toString()}function me(e,t=Ze){return t(e)}function ne(e,t=et){return t(e)}var tt=()=>typeof window<"u"&&window.document&&window.document.nodeType===9;function rt(){if(tt())return window.navigator.userAgent;let e=process?.version.slice(1)||"unknow",t=`(${process.platform}; ${process.arch})`;return`node.js/${e} ${t}`}function se(e){let t=null,r=null;if(!e)throw new Error("Missing required option `name`");let o=e.version?`${e.name}/${e.version}`:e.name;e.libraryName&&!e.libraryVersion?t=e.libraryName:e.libraryName&&e.libraryVersion&&(t=`${e.libraryName}/${e.libraryVersion}`),e.contactUrl&&!e.contactEmail?r=`(+${e.contactUrl})`:!e.contactUrl&&e.contactEmail?r=`(+${e.contactEmail})`:e.contactUrl&&e.contactEmail&&(r=`(+${e.contactUrl}; +${e.contactEmail})`);let i=rt(),s=e.customAgent||"";return[o,i,t,r,s].filter(Boolean).join(" ")}function ye(e){if(!e.host)throw new Error("Request `host` or `url` is missing or invalid, please pass in a valid host e.g `host: http://a-valid-host-url`");if(!e.httpClient&&typeof e.httpClient!="function")throw new Error("An `httpClient` is not available, please pass in a `fetch` or `axios` instance as an option or have them globally available.");if(e.httpClientOptions&&Object.prototype.toString.call(e.httpClientOptions)!=="[object Object]")throw new Error("`httpClientOptions` must be an object type")}function we(e){if(!Array.isArray(e))throw new Error("`retryCodes` option must be an array of retry status (error) codes and/or messages.")}function Me(e){if(!e)throw new Error("Missing required options");if(e.middlewares&&!Array.isArray(e.middlewares))throw new Error("Middlewares should be an array");if(!e.middlewares||!Array.isArray(e.middlewares)||!e.middlewares.length)throw new Error("You need to provide at least one middleware")}function ae(e,t,r={allowedMethods:fe}){if(!t)throw new Error(`The "${e}" function requires a "Request" object as an argument. See https://commercetools.github.io/nodejs/sdk/Glossary.html#clientrequest`);if(typeof t.uri!="string")throw new Error(`The "${e}" Request object requires a valid uri. See https://commercetools.github.io/nodejs/sdk/Glossary.html#clientrequest`);if(!r.allowedMethods.includes(t.method))throw new Error(`The "${e}" Request object requires a valid method. See https://commercetools.github.io/nodejs/sdk/Glossary.html#clientrequest`)}function ge(e){if(!e)throw new Error("Missing required options");if(!e.host)throw new Error("Missing required option (host)");if(!e.projectKey)throw new Error("Missing required option (projectKey)");if(!e.credentials)throw new Error("Missing required option (credentials)");let{clientId:t,clientSecret:r}=e.credentials||{};if(!(t&&r))throw new Error("Missing required credentials (clientId, clientSecret)");let o=e.scopes?e.scopes.join(" "):void 0,i=btoa(`${t}:${r}`),s=e.oauthUri||"/oauth/token",a=e.host.replace(/\/$/,"")+s,n=`grant_type=client_credentials${o?`&scope=${o}`:""}`;return{url:a,body:n,basicAuth:i}}function Ee(e){if(!e)throw new Error("Missing required options");if(!e.projectKey)throw new Error("Missing required option (projectKey)");let t=e.projectKey;e.oauthUri=e.oauthUri||`/oauth/${t}/anonymous/token`;let r=ge(e);return e.credentials.anonymousId&&(r.body+=`&anonymous_id=${e.credentials.anonymousId}`),{...r}}function le(e){if(!e)throw new Error("Missing required options");if(!e.host)throw new Error("Missing required option (host)");if(!e.projectKey)throw new Error("Missing required option (projectKey)");if(!e.credentials)throw new Error("Missing required option (credentials)");if(!e.refreshToken)throw new Error("Missing required option (refreshToken)");let{clientId:t,clientSecret:r}=e.credentials;if(!(t&&r))throw new Error("Missing required credentials (clientId, clientSecret)");let o=btoa(`${t}:${r}`),i=e.oauthUri||"/oauth/token",s=e.host.replace(/\/$/,"")+i,a=`grant_type=refresh_token&refresh_token=${encodeURIComponent(e.refreshToken)}`;return{basicAuth:o,url:s,body:a}}function Oe(e){if(!e)throw new Error("Missing required options");if(!e.host)throw new Error("Missing required option (host)");if(!e.projectKey)throw new Error("Missing required option (projectKey)");if(!e.credentials)throw new Error("Missing required option (credentials)");let{clientId:t,clientSecret:r,user:o}=e.credentials,i=e.projectKey;if(!(t&&r&&o))throw new Error("Missing required credentials (clientId, clientSecret, user)");let{username:s,password:a}=o;if(!(s&&a))throw new Error("Missing required user credentials (username, password)");let n=(e.scopes||[]).join(" "),u=n?`&scope=${n}`:"",l=btoa(`${t}:${r}`),d=e.oauthUri||`/oauth/${i}/customers/token`,c=e.host.replace(/\/$/,"")+d,M=`grant_type=password&username=${encodeURIComponent(s)}&password=${encodeURIComponent(a)}${u}`;return{basicAuth:l,url:c,body:M}}async function Ce(e){let{httpClient:t,httpClientOptions:r,tokenCache:o,userOption:i,tokenCacheObject:s}=e,a=e.url,n=e.body,u=e.basicAuth;if(!t||typeof t!="function")throw new Error("an `httpClient` is not available, please pass in a `fetch` or `axios` instance as an option or have them globally available.");if(s&&s.refreshToken&&(!s.token||s.token&&Date.now()>s.expirationTime)){if(!i)throw new Error("Missing required options.");let d={...le({...i,refreshToken:s.refreshToken})};a=d.url,n=d.body,u=d.basicAuth}let l;try{if(l=await U({url:a,method:"POST",headers:{Authorization:`Basic ${u}`,"Content-Type":"application/x-www-form-urlencoded","Content-Length":I(n)},httpClient:t,httpClientOptions:r,body:n}),l.statusCode>=200&&l.statusCode<300){let{access_token:d,expires_in:c,refresh_token:M}=l?.data,C=ie(c);return o.set({token:d,expirationTime:C,refreshToken:M}),Promise.resolve(!0)}throw N({code:l.data.error,statusCode:l.data.statusCode,message:l.data.message,error:l.data.errors})}catch(d){throw d}}async function E(e,t=null,r,o,i,s,a,n){let u={request:e,tokenCache:i,httpClient:a.httpClient||fetch,httpClientOptions:a.httpClientOptions,...s(a),userOption:a,next:n},l=async d=>{let c=Object.assign({},d);return c.statusCode==401&&(t=Ce(u),await t,t=null,r=i.get(o),c=await n(j(r.token,e))),c};return e.headers&&(e.headers.Authorization||e.headers.authorization)?l(await n(e)):(r=i.get(o),r&&r.token&&Date.now()<r.expirationTime?l(await n(j(r.token,e))):(t?await t:(t=Ce(u),await t,t=null),r=i.get(o),n(j(r.token,e))))}function v(e){let t=e.tokenCache||A({token:"",expirationTime:-1}),r,o=null,i=R(e);return s=>async a=>E(a,o,r,i,t,Ee,e,s)}function H(e){let t=e.tokenCache||A({token:"",expirationTime:-1}),r,o=null,i=R(e);return s=>async a=>E(a,o,r,i,t,ge,e,s)}function _(e,t){return r=>async o=>{if(typeof e!="string")throw new Error("authorization must be a string");let i=t?.force===void 0?!0:t.force;if(!e||o.headers&&(o.headers.Authorization||o.headers.authorization)&&i===!1)return r(o);let s={...o,headers:{...o.headers,Authorization:e}};return r(s)}}function B(e){let t=e.tokenCache||A({token:"",expirationTime:-1}),r,o=null,i=R(e);return s=>async a=>E(a,o,r,i,t,Oe,e,s)}function K(e){let t=e.tokenCache||A({token:"",tokenCacheKey:null}),r,o=null,i=R(e);return s=>async a=>E(a,o,r,i,t,le,e,s)}function z(e){return t=>async r=>{let o=await t(r);if(o.statusCode==409){let i=o.error.body?.errors?.[0]?.currentVersion;if(i)return e&&typeof e=="function"?r.body=await e(i,r,o):r.body=typeof r.body=="string"?{...JSON.parse(r.body),version:i}:{...r.body,version:i},t(r)}return o}}function J(e){return t=>r=>{let o={...r,headers:{...r.headers,"X-Correlation-ID":e.generate&&typeof e.generate=="function"?e.generate():oe()}};return t(o)}}function Re(e){return t=>async r=>{let o=await t(r);if(o.error){let{error:i}=o;return{...o,statusCode:i.statusCode||0,headers:i.headers||T({}),error:{...i,body:i.data||i}}}return o}}async function ot({url:e,httpClient:t,clientOptions:r}){let{request:o,maskSensitiveHeaderData:i,includeRequestInErrorResponse:s,includeResponseHeaders:a}=r;try{let n=await U({url:e,...r,httpClient:t,method:r.method,...r.body?{body:r.body}:{}});if(a||(n.headers=null),n.statusCode>=200&&n.statusCode<300)return r.method=="HEAD"?{body:null,statusCode:n.statusCode,retryCount:n.retryCount,headers:T(n.headers)}:{body:n.data,statusCode:n.statusCode,retryCount:n.retryCount,headers:T(n.headers)};let u=N({code:n.data?.errors?.[0].code,message:n?.data?.message||n?.message,statusCode:n.statusCode||n?.data?.statusCode,method:r.method,headers:T(n.headers),body:n.data,error:n.data,retryCount:n.retryCount,...s?{originalRequest:i?k(o):o}:{uri:o.uri}});return{...u,error:u}}catch(n){let u=a?T(n.response?.headers):null,l=n.response?.status||n.response?.statusCode||n.response?.data.statusCode||0,d=n.response?.data?.message;throw{body:null,error:N({statusCode:l,code:"NetworkError",status:l,message:d||n.message,headers:u,body:n.response?.data||n,error:n.response?.data||n,...s?{originalRequest:i?k(o):o}:{uri:o.uri}})}}}function V(e){ye(e);let{host:t,credentialsMode:r,httpClient:o,timeout:i,enableRetry:s,retryConfig:a,getAbortController:n,includeOriginalRequest:u,includeRequestInErrorResponse:l=!0,includeResponseHeaders:d=!0,maskSensitiveHeaderData:c,httpClientOptions:M}=e;return C=>async p=>{let S=t.replace(/\/$/,"")+p.uri,h={...p.headers};Object.prototype.hasOwnProperty.call(h,"Content-Type")||Object.prototype.hasOwnProperty.call(h,"content-type")||(h["Content-Type"]="application/json"),h["Content-Type"]===null&&delete h["Content-Type"];let w=g.HEADERS_CONTENT_TYPES.indexOf(h["Content-Type"])>-1&&typeof p.body=="string"||Q(p.body)?p.body:JSON.stringify(p.body||void 0);w&&(typeof w=="string"||Q(w))&&(h["Content-Length"]=I(w));let f={enableRetry:s,retryConfig:a,request:p,method:p.method,headers:h,includeRequestInErrorResponse:l,maskSensitiveHeaderData:c,includeResponseHeaders:d,...M};r&&(f.credentialsMode=r),i&&(f.timeout=i,f.getAbortController=n),w&&(f.body=w);let q=await ot({url:S,clientOptions:f,httpClient:o}),x={...p,includeOriginalRequest:u,maskSensitiveHeaderData:c,response:q};return C(x)}}function G(e){return t=>async r=>{let o=await t(r),i=Object.assign({},o),{loggerFn:s=console.log}=e||{};return s&&typeof s=="function"&&s(o),i}}function Y({concurrency:e=20}){let t=0,r=[],o=()=>0>=e?Promise.resolve():new Promise(s=>{let a=()=>{t<e?(t++,s()):r.push(a)};a()}),i=()=>{if(t--,r.length>0){let s=r.shift();s&&s()}};return s=>a=>o().then(()=>{let n={...a,resolve(u){a.resolve(u),i()},reject(u){a.reject(u),i()}};return s(n).finally(()=>{i()})})}var ke={name:"@commercetools/ts-client",version:"3.2.0",engines:{node:">=18"},description:"commercetools Composable Commerce TypeScript SDK client.",keywords:["commercetools","composable commerce","sdk","typescript","client","middleware","http","oauth","auth"],homepage:"https://github.com/commercetools/commercetools-sdk-typescript",license:"MIT",directories:{lib:"lib",test:"test"},publishConfig:{access:"public"},repository:{type:"git",url:"git+https://github.com/commercetools/commercetools-sdk-typescript.git"},bugs:{url:"https://github.com/commercetools/commercetools-sdk-typescript/issues"},dependencies:{buffer:"^6.0.3"},files:["dist","CHANGELOG.md"],author:"Chukwuemeka Ajima <meeky.ae@gmail.com>",main:"dist/commercetools-ts-client.cjs.js",module:"dist/commercetools-ts-client.esm.js",browser:{"./dist/commercetools-ts-client.cjs.js":"./dist/commercetools-ts-client.browser.cjs.js","./dist/commercetools-ts-client.esm.js":"./dist/commercetools-ts-client.browser.esm.js"},devDependencies:{"common-tags":"1.8.2",dotenv:"16.4.7",jest:"29.7.0",nock:"14.0.1","organize-imports-cli":"0.10.0"},scripts:{organize_imports:"find src -type f -name '*.ts' | xargs organize-imports-cli",postbuild:"yarn organize_imports",post_process_generate:"yarn organize_imports",docs:"typedoc --out docs"}};function W(e){return t=>async r=>{let o=se({...e,name:`${e.name?e.name+"/":""}commercetools-sdk-javascript-v3/${ke.version}`}),i={...r,headers:{...r.headers,"User-Agent":o}};return t(i)}}function nt({middlewares:e}){return e.length===1?e[0]:e.slice().reduce((r,o)=>(...i)=>r(o.apply(null,i)))}var Pe;function de(e,t,r){if(ae("process",e,{allowedMethods:["GET"]}),typeof t!="function")throw new Error('The "process" function accepts a "Function" as a second argument that returns a Promise. See https://commercetools.github.io/nodejs/sdk/api/sdkClient.html#processrequest-processfn-options');let o={total:Number.POSITIVE_INFINITY,accumulate:!0,...r};return new Promise((i,s)=>{let a,n="";if(e&&e.uri){let[C,p]=e.uri.split("?");a=C,n=p}let l={limit:20,...{...me(n)}},d=o.total,c=!1,M=async(C,p=[])=>{let S=l.limit<d?l.limit:d,h=ne({...l,limit:S}),w={sort:"id asc",withTotal:!1,...C?{where:`id > "${C}"`}:{}},f=ne(w),q={...e,uri:`${a}?${f}&${h}`};try{let x=await P(Pe).execute(q),{results:X,count:F}=x?.body||{};if(!F&&c)return i(p||[]);let m=await Promise.resolve(t(x)),y;if(c=!0,o.accumulate&&(y=p.concat(m||[])),d-=F,F<l.limit||!d)return i(y||[]);let $=X[F-1],Z=$&&$.id;M(Z,y)}catch(x){s(x)}};M()})}function P(e){Pe=e,Me(e);let t=!1,r={async resolve(i){let{response:s,includeOriginalRequest:a,maskSensitiveHeaderData:n,...u}=i,{retryCount:l,...d}=s;return t=n,{body:null,error:null,reject:i.reject,resolve:i.resolve,...d,...a?{originalRequest:u}:{},...s?.retryCount?{retryCount:s.retryCount}:{}}}},o=nt(e)(r.resolve);return{process:de,execute(i){return ae("exec",i),new Promise(async(s,a)=>{try{let n=await o({reject:a,resolve:s,...i});if(n.error)return a(n.error);n.originalRequest&&t&&(n.originalRequest=k(n.originalRequest)),s(n)}catch(n){a(n)}})}}}var{createAuthMiddlewareForPasswordFlow:st,createAuthMiddlewareForAnonymousSessionFlow:at,createAuthMiddlewareForClientCredentialsFlow:lt,createAuthMiddlewareForRefreshTokenFlow:dt,createAuthMiddlewareForExistingTokenFlow:ut,createCorrelationIdMiddleware:ct,createHttpMiddleware:pt,createLoggerMiddleware:ht,createQueueMiddleware:wt,createUserAgentMiddleware:Se,createConcurrentModificationMiddleware:ft}=Ae,L=class{projectKey;authMiddleware;httpMiddleware;userAgentMiddleware;correlationIdMiddleware;loggerMiddleware;queueMiddleware;concurrentMiddleware;telemetryMiddleware;beforeMiddleware;afterMiddleware;middlewares=[];constructor(){this.userAgentMiddleware=Se({})}withProjectKey(t){return this.projectKey=t,this}defaultClient(t,r,o,i,s,a){return this.withClientCredentialsFlow({host:o,projectKey:i||this.projectKey,credentials:r,httpClient:a||fetch,scopes:s}).withHttpMiddleware({host:t,httpClient:a||fetch})}withAuthMiddleware(t){return this.authMiddleware=t,this}withMiddleware(t){return this.middlewares.push(t),this}withClientCredentialsFlow(t){return this.withAuthMiddleware(lt({host:t.host||g.CTP_AUTH_URL,projectKey:t.projectKey||this.projectKey,credentials:{clientId:t.credentials.clientId||null,clientSecret:t.credentials.clientSecret||null},oauthUri:t.oauthUri||null,scopes:t.scopes,httpClient:t.httpClient||fetch,...t}))}withPasswordFlow(t){return this.withAuthMiddleware(st({host:t.host||g.CTP_AUTH_URL,projectKey:t.projectKey||this.projectKey,credentials:{clientId:t.credentials.clientId||null,clientSecret:t.credentials.clientSecret||null,user:{username:t.credentials.user.username||null,password:t.credentials.user.password||null}},httpClient:t.httpClient||fetch,...t}))}withAnonymousSessionFlow(t){return this.withAuthMiddleware(at({host:t.host||g.CTP_AUTH_URL,projectKey:this.projectKey||t.projectKey,credentials:{clientId:t.credentials.clientId||null,clientSecret:t.credentials.clientSecret||null,anonymousId:t.credentials.anonymousId||null},httpClient:t.httpClient||fetch,...t}))}withRefreshTokenFlow(t){return this.withAuthMiddleware(dt({host:t.host||g.CTP_AUTH_URL,projectKey:this.projectKey||t.projectKey,credentials:{clientId:t.credentials.clientId||null,clientSecret:t.credentials.clientSecret||null},httpClient:t.httpClient||fetch,refreshToken:t.refreshToken||null,...t}))}withExistingTokenFlow(t,r){return this.withAuthMiddleware(ut(t,{force:r.force||!0,...r}))}withHttpMiddleware(t){return this.httpMiddleware=pt({host:t.host||g.CTP_API_URL,httpClient:t.httpClient||fetch,...t}),this}withUserAgentMiddleware(t){return this.userAgentMiddleware=Se(t),this}withQueueMiddleware(t){return this.queueMiddleware=wt({concurrency:t.concurrency||g.CONCURRENCT_REQUEST,...t}),this}withLoggerMiddleware(t){return this.loggerMiddleware=ht(t),this}withCorrelationIdMiddleware(t){return this.correlationIdMiddleware=ct({generate:t?.generate,...t}),this}withConcurrentModificationMiddleware(t){return this.concurrentMiddleware=ft(t?.concurrentModificationHandlerFn),this}withTelemetryMiddleware(t){let{createTelemetryMiddleware:r,...o}=t;return this.withUserAgentMiddleware({customAgent:o?.userAgent||"typescript-sdk-apm-middleware"}),this.telemetryMiddleware=r(o),this}withBeforeExecutionMiddleware(t){let{middleware:r,...o}=t||{};return this.beforeMiddleware=t.middleware(o),this}withAfterExecutionMiddleware(t){let{middleware:r,...o}=t||{};return this.afterMiddleware=t.middleware(o),this}build(){let t=this.middlewares.slice();return this.telemetryMiddleware&&t.push(this.telemetryMiddleware),this.correlationIdMiddleware&&t.push(this.correlationIdMiddleware),this.userAgentMiddleware&&t.push(this.userAgentMiddleware),this.authMiddleware&&t.push(this.authMiddleware),this.beforeMiddleware&&t.push(this.beforeMiddleware),this.queueMiddleware&&t.push(this.queueMiddleware),this.loggerMiddleware&&t.push(this.loggerMiddleware),this.concurrentMiddleware&&t.push(this.concurrentMiddleware),this.httpMiddleware&&t.push(this.httpMiddleware),this.afterMiddleware&&t.push(this.afterMiddleware),P({middlewares:t})}};return je(mt);})();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anonymous-session-flow.d.ts","sourceRoot":"../../../../../src/middleware/auth-middleware","sources":["anonymous-session-flow.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,UAAU,EAMX,6BAAyB;AAK1B,MAAM,CAAC,OAAO,UAAU,2CAA2C,CACjE,OAAO,EAAE,qBAAqB,GAC7B,UAAU,
|
|
1
|
+
{"version":3,"file":"anonymous-session-flow.d.ts","sourceRoot":"../../../../../src/middleware/auth-middleware","sources":["anonymous-session-flow.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,UAAU,EAMX,6BAAyB;AAK1B,MAAM,CAAC,OAAO,UAAU,2CAA2C,CACjE,OAAO,EAAE,qBAAqB,GAC7B,UAAU,CA0BZ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client-credentials-flow.d.ts","sourceRoot":"../../../../../src/middleware/auth-middleware","sources":["client-credentials-flow.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,UAAU,EAMX,6BAAyB;AAK1B,MAAM,CAAC,OAAO,UAAU,4CAA4C,CAClE,OAAO,EAAE,qBAAqB,GAC7B,UAAU,
|
|
1
|
+
{"version":3,"file":"client-credentials-flow.d.ts","sourceRoot":"../../../../../src/middleware/auth-middleware","sources":["client-credentials-flow.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,UAAU,EAMX,6BAAyB;AAK1B,MAAM,CAAC,OAAO,UAAU,4CAA4C,CAClE,OAAO,EAAE,qBAAqB,GAC7B,UAAU,CA0BZ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"password-flow.d.ts","sourceRoot":"../../../../../src/middleware/auth-middleware","sources":["password-flow.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EAIV,6BAA6B,EAE9B,6BAAyB;AAK1B,MAAM,CAAC,OAAO,UAAU,mCAAmC,CACzD,OAAO,EAAE,6BAA6B,GACrC,UAAU,
|
|
1
|
+
{"version":3,"file":"password-flow.d.ts","sourceRoot":"../../../../../src/middleware/auth-middleware","sources":["password-flow.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EAIV,6BAA6B,EAE9B,6BAAyB;AAK1B,MAAM,CAAC,OAAO,UAAU,mCAAmC,CACzD,OAAO,EAAE,6BAA6B,GACrC,UAAU,CA0BZ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refresh-token-flow.d.ts","sourceRoot":"../../../../../src/middleware/auth-middleware","sources":["refresh-token-flow.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EAIV,4BAA4B,EAE7B,6BAAyB;AAK1B,MAAM,CAAC,OAAO,UAAU,uCAAuC,CAC7D,OAAO,EAAE,4BAA4B,GACpC,UAAU,
|
|
1
|
+
{"version":3,"file":"refresh-token-flow.d.ts","sourceRoot":"../../../../../src/middleware/auth-middleware","sources":["refresh-token-flow.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EAIV,4BAA4B,EAE7B,6BAAyB;AAK1B,MAAM,CAAC,OAAO,UAAU,uCAAuC,CAC7D,OAAO,EAAE,4BAA4B,GACpC,UAAU,CA0BZ"}
|