@kard-financial/sdk 12.3.0 → 13.0.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 +106 -15
- package/dist/cjs/BaseClient.d.ts +7 -8
- package/dist/cjs/BaseClient.js +3 -3
- package/dist/cjs/Client.d.ts +13 -2
- package/dist/cjs/Client.js +67 -0
- package/dist/cjs/api/resources/auth/client/Client.d.ts +1 -2
- package/dist/cjs/api/resources/auth/client/Client.js +3 -23
- package/dist/cjs/api/resources/auth/exports.d.ts +2 -0
- package/dist/cjs/api/resources/auth/exports.js +21 -0
- package/dist/cjs/api/resources/commons/errors/ConflictError.js +5 -1
- package/dist/cjs/api/resources/commons/errors/DoesNotExistError.js +5 -1
- package/dist/cjs/api/resources/commons/errors/ForbiddenError.js +5 -1
- package/dist/cjs/api/resources/commons/errors/InternalServerError.js +5 -1
- package/dist/cjs/api/resources/commons/errors/InvalidRequest.js +5 -1
- package/dist/cjs/api/resources/commons/errors/UnauthorizedError.js +5 -1
- package/dist/cjs/api/resources/commons/exports.d.ts +1 -0
- package/dist/cjs/api/resources/commons/exports.js +18 -0
- package/dist/cjs/api/resources/commons/types/ErrorObject.d.ts +2 -2
- package/dist/cjs/api/resources/commons/types/ErrorSource.d.ts +3 -3
- package/dist/cjs/api/resources/commons/types/Links.d.ts +2 -2
- package/dist/cjs/api/resources/files/client/Client.d.ts +1 -2
- package/dist/cjs/api/resources/files/client/Client.js +11 -47
- package/dist/cjs/api/resources/files/exports.d.ts +2 -0
- package/dist/cjs/api/resources/files/exports.js +21 -0
- package/dist/cjs/api/resources/notifications/client/Client.d.ts +1 -2
- package/dist/cjs/api/resources/notifications/exports.d.ts +3 -0
- package/dist/cjs/api/resources/notifications/exports.js +22 -0
- package/dist/cjs/api/resources/notifications/resources/subscriptions/client/Client.d.ts +1 -2
- package/dist/cjs/api/resources/notifications/resources/subscriptions/client/Client.js +7 -64
- package/dist/cjs/api/resources/notifications/resources/subscriptions/exports.d.ts +2 -0
- package/dist/cjs/api/resources/notifications/resources/subscriptions/exports.js +21 -0
- package/dist/cjs/api/resources/notifications/resources/subscriptions/types/UpdateSubscriptionRequestAttributes.d.ts +3 -3
- package/dist/cjs/api/resources/notifications/types/AuditUpdateAttributes.d.ts +3 -3
- package/dist/cjs/api/resources/notifications/types/FailedTransactionAttributes.d.ts +1 -1
- package/dist/cjs/api/resources/notifications/types/NotificationPayload.d.ts +2 -2
- package/dist/cjs/api/resources/notifications/types/RewardNotificationAttributes.d.ts +2 -2
- package/dist/cjs/api/resources/ping/client/Client.d.ts +1 -2
- package/dist/cjs/api/resources/ping/client/Client.js +2 -20
- package/dist/cjs/api/resources/ping/errors/NetworkBlockedError.js +5 -1
- package/dist/cjs/api/resources/ping/exports.d.ts +2 -0
- package/dist/cjs/api/resources/ping/exports.js +21 -0
- package/dist/cjs/api/resources/transactions/client/Client.d.ts +3 -3
- package/dist/cjs/api/resources/transactions/client/Client.js +16 -115
- package/dist/cjs/api/resources/transactions/client/requests/GetEarnedRewardsRequest.d.ts +3 -0
- package/dist/cjs/api/resources/transactions/errors/CreateAuditMultiStatus.js +5 -1
- package/dist/cjs/api/resources/transactions/errors/CreateIncomingTransactionsMultiStatus.js +5 -1
- package/dist/cjs/api/resources/transactions/errors/FraudMultiStatus.js +5 -1
- package/dist/cjs/api/resources/transactions/exports.d.ts +2 -0
- package/dist/cjs/api/resources/transactions/exports.js +21 -0
- package/dist/cjs/api/resources/transactions/types/CoreTransactionAttributes.d.ts +3 -3
- package/dist/cjs/api/resources/transactions/types/CreateAuditMultiStatusResponse.d.ts +1 -1
- package/dist/cjs/api/resources/transactions/types/GetEarnedRewardsMeta.d.ts +4 -0
- package/dist/cjs/api/resources/transactions/types/GetEarnedRewardsMeta.js +3 -0
- package/dist/cjs/api/resources/transactions/types/GetEarnedRewardsResponse.d.ts +50 -2
- package/dist/cjs/api/resources/transactions/types/MatchedTransactionsAttributes.d.ts +14 -14
- package/dist/cjs/api/resources/transactions/types/Merchant.d.ts +9 -9
- package/dist/cjs/api/resources/transactions/types/RewardedTransactionAttributes.d.ts +3 -3
- package/dist/cjs/api/resources/transactions/types/RewardedTransactionStatus.d.ts +1 -0
- package/dist/cjs/api/resources/transactions/types/RewardedTransactionStatus.js +1 -0
- package/dist/cjs/api/resources/transactions/types/TransactionsAttributes.d.ts +18 -18
- package/dist/cjs/api/resources/transactions/types/index.d.ts +1 -0
- package/dist/cjs/api/resources/transactions/types/index.js +1 -0
- package/dist/cjs/api/resources/users/client/Client.d.ts +1 -2
- package/dist/cjs/api/resources/users/client/Client.js +5 -80
- package/dist/cjs/api/resources/users/errors/MultiStatus.js +5 -1
- package/dist/cjs/api/resources/users/exports.d.ts +3 -0
- package/dist/cjs/api/resources/users/exports.js +22 -0
- package/dist/cjs/api/resources/users/resources/attributions/client/Client.d.ts +1 -2
- package/dist/cjs/api/resources/users/resources/attributions/client/Client.js +20 -94
- package/dist/cjs/api/resources/users/resources/attributions/exports.d.ts +2 -0
- package/dist/cjs/api/resources/users/resources/attributions/exports.js +21 -0
- package/dist/cjs/api/resources/users/resources/attributions/types/ActivateOfferResponse.d.ts +1 -1
- package/dist/cjs/api/resources/users/resources/attributions/types/AttributionState.d.ts +2 -2
- package/dist/cjs/api/resources/users/resources/attributions/types/BoostOfferResponse.d.ts +1 -1
- package/dist/cjs/api/resources/users/resources/attributions/types/NotificationAttributionAttributes.d.ts +1 -1
- package/dist/cjs/api/resources/users/resources/attributions/types/OfferAttributionAttributes.d.ts +1 -1
- package/dist/cjs/api/resources/users/resources/auth/client/Client.d.ts +1 -2
- package/dist/cjs/api/resources/users/resources/auth/client/Client.js +2 -20
- package/dist/cjs/api/resources/users/resources/auth/exports.d.ts +2 -0
- package/dist/cjs/api/resources/users/resources/auth/exports.js +21 -0
- package/dist/cjs/api/resources/users/resources/rewards/client/Client.d.ts +1 -2
- package/dist/cjs/api/resources/users/resources/rewards/client/Client.js +39 -144
- package/dist/cjs/api/resources/users/resources/rewards/exports.d.ts +2 -0
- package/dist/cjs/api/resources/users/resources/rewards/exports.js +21 -0
- package/dist/cjs/api/resources/users/resources/rewards/types/CtaComponent.d.ts +2 -2
- package/dist/cjs/api/resources/users/resources/rewards/types/LocationData.d.ts +1 -1
- package/dist/cjs/api/resources/users/resources/rewards/types/LocationsResponseObject.d.ts +1 -1
- package/dist/cjs/api/resources/users/resources/rewards/types/LogoFlare.d.ts +1 -1
- package/dist/cjs/api/resources/users/resources/rewards/types/OfferCommonFields.d.ts +8 -8
- package/dist/cjs/api/resources/users/resources/rewards/types/OfferComponents.d.ts +9 -9
- package/dist/cjs/api/resources/users/resources/rewards/types/OffersMeta.d.ts +1 -1
- package/dist/cjs/api/resources/users/resources/rewards/types/OffersResponseObject.d.ts +2 -2
- package/dist/cjs/api/resources/users/resources/rewards/types/ProgressBar.d.ts +1 -1
- package/dist/cjs/api/resources/users/resources/rewards/types/ProgressBarLabelPair.d.ts +2 -2
- package/dist/cjs/api/resources/users/resources/rewards/types/ProgressBarLabels.d.ts +1 -1
- package/dist/cjs/api/resources/users/resources/rewards/types/ProgressBarSegment.d.ts +1 -1
- package/dist/cjs/api/resources/users/resources/rewards/types/ProgressBarSegments.d.ts +1 -1
- package/dist/cjs/api/resources/users/resources/rewards/types/StandardOffer.d.ts +1 -1
- package/dist/cjs/api/resources/users/resources/uploads/client/Client.d.ts +1 -2
- package/dist/cjs/api/resources/users/resources/uploads/client/Client.js +4 -60
- package/dist/cjs/api/resources/users/resources/uploads/errors/UploadPartMultiStatus.js +5 -1
- package/dist/cjs/api/resources/users/resources/uploads/exports.d.ts +2 -0
- package/dist/cjs/api/resources/users/resources/uploads/exports.js +21 -0
- package/dist/cjs/api/resources/users/resources/uploads/types/CreateUploadPartMultiStatusResponse.d.ts +1 -1
- package/dist/cjs/api/resources/users/types/CreateUsersMultiStatusResponse.d.ts +1 -1
- package/dist/cjs/api/resources/users/types/UpdateUserRequestAttributes.d.ts +5 -5
- package/dist/cjs/api/resources/users/types/UserRequestAttributes.d.ts +6 -6
- package/dist/cjs/auth/OAuthAuthProvider.d.ts +36 -14
- package/dist/cjs/auth/OAuthAuthProvider.js +108 -40
- package/dist/cjs/core/auth/BasicAuth.d.ts +2 -2
- package/dist/cjs/core/auth/BasicAuth.js +7 -1
- package/dist/cjs/core/fetcher/BinaryResponse.d.ts +1 -1
- package/dist/cjs/core/fetcher/EndpointSupplier.d.ts +2 -2
- package/dist/cjs/core/fetcher/Fetcher.d.ts +3 -2
- package/dist/cjs/core/fetcher/Fetcher.js +12 -2
- package/dist/cjs/core/fetcher/index.d.ts +2 -0
- package/dist/cjs/core/fetcher/index.js +3 -1
- package/dist/cjs/core/fetcher/makePassthroughRequest.d.ts +49 -0
- package/dist/cjs/core/fetcher/makePassthroughRequest.js +135 -0
- package/dist/cjs/core/fetcher/makeRequest.d.ts +6 -1
- package/dist/cjs/core/fetcher/makeRequest.js +30 -9
- package/dist/cjs/core/headers.d.ts +2 -2
- package/dist/cjs/core/runtime/runtime.js +8 -7
- package/dist/cjs/errors/KardApiError.d.ts +3 -1
- package/dist/cjs/errors/KardApiError.js +9 -2
- package/dist/cjs/errors/KardApiTimeoutError.d.ts +4 -1
- package/dist/cjs/errors/KardApiTimeoutError.js +9 -2
- package/dist/cjs/errors/handleNonStatusCodeError.d.ts +2 -0
- package/dist/cjs/errors/handleNonStatusCodeError.js +68 -0
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/BaseClient.d.mts +7 -8
- package/dist/esm/BaseClient.mjs +3 -3
- package/dist/esm/Client.d.mts +13 -2
- package/dist/esm/Client.mjs +34 -0
- package/dist/esm/api/resources/auth/client/Client.d.mts +1 -2
- package/dist/esm/api/resources/auth/client/Client.mjs +3 -23
- package/dist/esm/api/resources/auth/exports.d.mts +2 -0
- package/dist/esm/api/resources/auth/exports.mjs +3 -0
- package/dist/esm/api/resources/commons/errors/ConflictError.mjs +5 -1
- package/dist/esm/api/resources/commons/errors/DoesNotExistError.mjs +5 -1
- package/dist/esm/api/resources/commons/errors/ForbiddenError.mjs +5 -1
- package/dist/esm/api/resources/commons/errors/InternalServerError.mjs +5 -1
- package/dist/esm/api/resources/commons/errors/InvalidRequest.mjs +5 -1
- package/dist/esm/api/resources/commons/errors/UnauthorizedError.mjs +5 -1
- package/dist/esm/api/resources/commons/exports.d.mts +1 -0
- package/dist/esm/api/resources/commons/exports.mjs +2 -0
- package/dist/esm/api/resources/commons/types/ErrorObject.d.mts +2 -2
- package/dist/esm/api/resources/commons/types/ErrorSource.d.mts +3 -3
- package/dist/esm/api/resources/commons/types/Links.d.mts +2 -2
- package/dist/esm/api/resources/files/client/Client.d.mts +1 -2
- package/dist/esm/api/resources/files/client/Client.mjs +11 -47
- package/dist/esm/api/resources/files/exports.d.mts +2 -0
- package/dist/esm/api/resources/files/exports.mjs +3 -0
- package/dist/esm/api/resources/notifications/client/Client.d.mts +1 -2
- package/dist/esm/api/resources/notifications/exports.d.mts +3 -0
- package/dist/esm/api/resources/notifications/exports.mjs +4 -0
- package/dist/esm/api/resources/notifications/resources/subscriptions/client/Client.d.mts +1 -2
- package/dist/esm/api/resources/notifications/resources/subscriptions/client/Client.mjs +7 -64
- package/dist/esm/api/resources/notifications/resources/subscriptions/exports.d.mts +2 -0
- package/dist/esm/api/resources/notifications/resources/subscriptions/exports.mjs +3 -0
- package/dist/esm/api/resources/notifications/resources/subscriptions/types/UpdateSubscriptionRequestAttributes.d.mts +3 -3
- package/dist/esm/api/resources/notifications/types/AuditUpdateAttributes.d.mts +3 -3
- package/dist/esm/api/resources/notifications/types/FailedTransactionAttributes.d.mts +1 -1
- package/dist/esm/api/resources/notifications/types/NotificationPayload.d.mts +2 -2
- package/dist/esm/api/resources/notifications/types/RewardNotificationAttributes.d.mts +2 -2
- package/dist/esm/api/resources/ping/client/Client.d.mts +1 -2
- package/dist/esm/api/resources/ping/client/Client.mjs +2 -20
- package/dist/esm/api/resources/ping/errors/NetworkBlockedError.mjs +5 -1
- package/dist/esm/api/resources/ping/exports.d.mts +2 -0
- package/dist/esm/api/resources/ping/exports.mjs +3 -0
- package/dist/esm/api/resources/transactions/client/Client.d.mts +3 -3
- package/dist/esm/api/resources/transactions/client/Client.mjs +16 -115
- package/dist/esm/api/resources/transactions/client/requests/GetEarnedRewardsRequest.d.mts +3 -0
- package/dist/esm/api/resources/transactions/errors/CreateAuditMultiStatus.mjs +5 -1
- package/dist/esm/api/resources/transactions/errors/CreateIncomingTransactionsMultiStatus.mjs +5 -1
- package/dist/esm/api/resources/transactions/errors/FraudMultiStatus.mjs +5 -1
- package/dist/esm/api/resources/transactions/exports.d.mts +2 -0
- package/dist/esm/api/resources/transactions/exports.mjs +3 -0
- package/dist/esm/api/resources/transactions/types/CoreTransactionAttributes.d.mts +3 -3
- package/dist/esm/api/resources/transactions/types/CreateAuditMultiStatusResponse.d.mts +1 -1
- package/dist/esm/api/resources/transactions/types/GetEarnedRewardsMeta.d.mts +4 -0
- package/dist/esm/api/resources/transactions/types/GetEarnedRewardsMeta.mjs +2 -0
- package/dist/esm/api/resources/transactions/types/GetEarnedRewardsResponse.d.mts +50 -2
- package/dist/esm/api/resources/transactions/types/MatchedTransactionsAttributes.d.mts +14 -14
- package/dist/esm/api/resources/transactions/types/Merchant.d.mts +9 -9
- package/dist/esm/api/resources/transactions/types/RewardedTransactionAttributes.d.mts +3 -3
- package/dist/esm/api/resources/transactions/types/RewardedTransactionStatus.d.mts +1 -0
- package/dist/esm/api/resources/transactions/types/RewardedTransactionStatus.mjs +1 -0
- package/dist/esm/api/resources/transactions/types/TransactionsAttributes.d.mts +18 -18
- package/dist/esm/api/resources/transactions/types/index.d.mts +1 -0
- package/dist/esm/api/resources/transactions/types/index.mjs +1 -0
- package/dist/esm/api/resources/users/client/Client.d.mts +1 -2
- package/dist/esm/api/resources/users/client/Client.mjs +5 -80
- package/dist/esm/api/resources/users/errors/MultiStatus.mjs +5 -1
- package/dist/esm/api/resources/users/exports.d.mts +3 -0
- package/dist/esm/api/resources/users/exports.mjs +4 -0
- package/dist/esm/api/resources/users/resources/attributions/client/Client.d.mts +1 -2
- package/dist/esm/api/resources/users/resources/attributions/client/Client.mjs +20 -94
- package/dist/esm/api/resources/users/resources/attributions/exports.d.mts +2 -0
- package/dist/esm/api/resources/users/resources/attributions/exports.mjs +3 -0
- package/dist/esm/api/resources/users/resources/attributions/types/ActivateOfferResponse.d.mts +1 -1
- package/dist/esm/api/resources/users/resources/attributions/types/AttributionState.d.mts +2 -2
- package/dist/esm/api/resources/users/resources/attributions/types/BoostOfferResponse.d.mts +1 -1
- package/dist/esm/api/resources/users/resources/attributions/types/NotificationAttributionAttributes.d.mts +1 -1
- package/dist/esm/api/resources/users/resources/attributions/types/OfferAttributionAttributes.d.mts +1 -1
- package/dist/esm/api/resources/users/resources/auth/client/Client.d.mts +1 -2
- package/dist/esm/api/resources/users/resources/auth/client/Client.mjs +2 -20
- package/dist/esm/api/resources/users/resources/auth/exports.d.mts +2 -0
- package/dist/esm/api/resources/users/resources/auth/exports.mjs +3 -0
- package/dist/esm/api/resources/users/resources/rewards/client/Client.d.mts +1 -2
- package/dist/esm/api/resources/users/resources/rewards/client/Client.mjs +39 -144
- package/dist/esm/api/resources/users/resources/rewards/exports.d.mts +2 -0
- package/dist/esm/api/resources/users/resources/rewards/exports.mjs +3 -0
- package/dist/esm/api/resources/users/resources/rewards/types/CtaComponent.d.mts +2 -2
- package/dist/esm/api/resources/users/resources/rewards/types/LocationData.d.mts +1 -1
- package/dist/esm/api/resources/users/resources/rewards/types/LocationsResponseObject.d.mts +1 -1
- package/dist/esm/api/resources/users/resources/rewards/types/LogoFlare.d.mts +1 -1
- package/dist/esm/api/resources/users/resources/rewards/types/OfferCommonFields.d.mts +8 -8
- package/dist/esm/api/resources/users/resources/rewards/types/OfferComponents.d.mts +9 -9
- package/dist/esm/api/resources/users/resources/rewards/types/OffersMeta.d.mts +1 -1
- package/dist/esm/api/resources/users/resources/rewards/types/OffersResponseObject.d.mts +2 -2
- package/dist/esm/api/resources/users/resources/rewards/types/ProgressBar.d.mts +1 -1
- package/dist/esm/api/resources/users/resources/rewards/types/ProgressBarLabelPair.d.mts +2 -2
- package/dist/esm/api/resources/users/resources/rewards/types/ProgressBarLabels.d.mts +1 -1
- package/dist/esm/api/resources/users/resources/rewards/types/ProgressBarSegment.d.mts +1 -1
- package/dist/esm/api/resources/users/resources/rewards/types/ProgressBarSegments.d.mts +1 -1
- package/dist/esm/api/resources/users/resources/rewards/types/StandardOffer.d.mts +1 -1
- package/dist/esm/api/resources/users/resources/uploads/client/Client.d.mts +1 -2
- package/dist/esm/api/resources/users/resources/uploads/client/Client.mjs +4 -60
- package/dist/esm/api/resources/users/resources/uploads/errors/UploadPartMultiStatus.mjs +5 -1
- package/dist/esm/api/resources/users/resources/uploads/exports.d.mts +2 -0
- package/dist/esm/api/resources/users/resources/uploads/exports.mjs +3 -0
- package/dist/esm/api/resources/users/resources/uploads/types/CreateUploadPartMultiStatusResponse.d.mts +1 -1
- package/dist/esm/api/resources/users/types/CreateUsersMultiStatusResponse.d.mts +1 -1
- package/dist/esm/api/resources/users/types/UpdateUserRequestAttributes.d.mts +5 -5
- package/dist/esm/api/resources/users/types/UserRequestAttributes.d.mts +6 -6
- package/dist/esm/auth/OAuthAuthProvider.d.mts +36 -14
- package/dist/esm/auth/OAuthAuthProvider.mjs +106 -39
- package/dist/esm/core/auth/BasicAuth.d.mts +2 -2
- package/dist/esm/core/auth/BasicAuth.mjs +7 -1
- package/dist/esm/core/fetcher/BinaryResponse.d.mts +1 -1
- package/dist/esm/core/fetcher/EndpointSupplier.d.mts +2 -2
- package/dist/esm/core/fetcher/Fetcher.d.mts +3 -2
- package/dist/esm/core/fetcher/Fetcher.mjs +12 -2
- package/dist/esm/core/fetcher/index.d.mts +2 -0
- package/dist/esm/core/fetcher/index.mjs +1 -0
- package/dist/esm/core/fetcher/makePassthroughRequest.d.mts +49 -0
- package/dist/esm/core/fetcher/makePassthroughRequest.mjs +132 -0
- package/dist/esm/core/fetcher/makeRequest.d.mts +6 -1
- package/dist/esm/core/fetcher/makeRequest.mjs +28 -9
- package/dist/esm/core/headers.d.mts +2 -2
- package/dist/esm/core/runtime/runtime.mjs +8 -7
- package/dist/esm/errors/KardApiError.d.mts +3 -1
- package/dist/esm/errors/KardApiError.mjs +9 -2
- package/dist/esm/errors/KardApiTimeoutError.d.mts +4 -1
- package/dist/esm/errors/KardApiTimeoutError.mjs +9 -2
- package/dist/esm/errors/handleNonStatusCodeError.d.mts +2 -0
- package/dist/esm/errors/handleNonStatusCodeError.mjs +32 -0
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +134 -10
- package/reference.md +3 -1
|
@@ -156,7 +156,13 @@ function getHeaders(args) {
|
|
|
156
156
|
return __awaiter(this, void 0, void 0, function* () {
|
|
157
157
|
var _a;
|
|
158
158
|
const newHeaders = new Headers_js_1.Headers();
|
|
159
|
-
newHeaders.set("Accept", args.responseType === "json"
|
|
159
|
+
newHeaders.set("Accept", args.responseType === "json"
|
|
160
|
+
? "application/json"
|
|
161
|
+
: args.responseType === "text"
|
|
162
|
+
? "text/plain"
|
|
163
|
+
: args.responseType === "sse"
|
|
164
|
+
? "text/event-stream"
|
|
165
|
+
: "*/*");
|
|
160
166
|
if (args.body !== undefined && args.contentType != null) {
|
|
161
167
|
newHeaders.set("Content-Type", args.contentType);
|
|
162
168
|
}
|
|
@@ -200,7 +206,7 @@ function fetcherImpl(args) {
|
|
|
200
206
|
}
|
|
201
207
|
try {
|
|
202
208
|
const response = yield (0, requestWithRetries_js_1.requestWithRetries)(() => __awaiter(this, void 0, void 0, function* () {
|
|
203
|
-
return (0, makeRequest_js_1.makeRequest)(fetchFn, url, args.method, headers, requestBody, args.timeoutMs, args.abortSignal, args.withCredentials, args.duplex);
|
|
209
|
+
return (0, makeRequest_js_1.makeRequest)(fetchFn, url, args.method, headers, requestBody, args.timeoutMs, args.abortSignal, args.withCredentials, args.duplex, args.responseType === "streaming" || args.responseType === "sse");
|
|
204
210
|
}), args.maxRetries);
|
|
205
211
|
if (response.status >= 200 && response.status < 400) {
|
|
206
212
|
if (logger.isDebug()) {
|
|
@@ -255,6 +261,7 @@ function fetcherImpl(args) {
|
|
|
255
261
|
error: {
|
|
256
262
|
reason: "unknown",
|
|
257
263
|
errorMessage: "The user aborted a request",
|
|
264
|
+
cause: error,
|
|
258
265
|
},
|
|
259
266
|
rawResponse: RawResponse_js_1.abortRawResponse,
|
|
260
267
|
};
|
|
@@ -272,6 +279,7 @@ function fetcherImpl(args) {
|
|
|
272
279
|
ok: false,
|
|
273
280
|
error: {
|
|
274
281
|
reason: "timeout",
|
|
282
|
+
cause: error,
|
|
275
283
|
},
|
|
276
284
|
rawResponse: RawResponse_js_1.abortRawResponse,
|
|
277
285
|
};
|
|
@@ -290,6 +298,7 @@ function fetcherImpl(args) {
|
|
|
290
298
|
error: {
|
|
291
299
|
reason: "unknown",
|
|
292
300
|
errorMessage: error.message,
|
|
301
|
+
cause: error,
|
|
293
302
|
},
|
|
294
303
|
rawResponse: RawResponse_js_1.unknownRawResponse,
|
|
295
304
|
};
|
|
@@ -307,6 +316,7 @@ function fetcherImpl(args) {
|
|
|
307
316
|
error: {
|
|
308
317
|
reason: "unknown",
|
|
309
318
|
errorMessage: (0, json_js_1.toJson)(error),
|
|
319
|
+
cause: error,
|
|
310
320
|
},
|
|
311
321
|
rawResponse: RawResponse_js_1.unknownRawResponse,
|
|
312
322
|
};
|
|
@@ -6,6 +6,8 @@ export type { Fetcher, FetchFunction } from "./Fetcher.js";
|
|
|
6
6
|
export { fetcher } from "./Fetcher.js";
|
|
7
7
|
export { getHeader } from "./getHeader.js";
|
|
8
8
|
export { HttpResponsePromise } from "./HttpResponsePromise.js";
|
|
9
|
+
export type { PassthroughRequest } from "./makePassthroughRequest.js";
|
|
10
|
+
export { makePassthroughRequest } from "./makePassthroughRequest.js";
|
|
9
11
|
export type { RawResponse, WithRawResponse } from "./RawResponse.js";
|
|
10
12
|
export { abortRawResponse, toRawResponse, unknownRawResponse } from "./RawResponse.js";
|
|
11
13
|
export { Supplier } from "./Supplier.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Supplier = exports.unknownRawResponse = exports.toRawResponse = exports.abortRawResponse = exports.HttpResponsePromise = exports.getHeader = exports.fetcher = exports.EndpointSupplier = void 0;
|
|
3
|
+
exports.Supplier = exports.unknownRawResponse = exports.toRawResponse = exports.abortRawResponse = exports.makePassthroughRequest = exports.HttpResponsePromise = exports.getHeader = exports.fetcher = exports.EndpointSupplier = void 0;
|
|
4
4
|
var EndpointSupplier_js_1 = require("./EndpointSupplier.js");
|
|
5
5
|
Object.defineProperty(exports, "EndpointSupplier", { enumerable: true, get: function () { return EndpointSupplier_js_1.EndpointSupplier; } });
|
|
6
6
|
var Fetcher_js_1 = require("./Fetcher.js");
|
|
@@ -9,6 +9,8 @@ var getHeader_js_1 = require("./getHeader.js");
|
|
|
9
9
|
Object.defineProperty(exports, "getHeader", { enumerable: true, get: function () { return getHeader_js_1.getHeader; } });
|
|
10
10
|
var HttpResponsePromise_js_1 = require("./HttpResponsePromise.js");
|
|
11
11
|
Object.defineProperty(exports, "HttpResponsePromise", { enumerable: true, get: function () { return HttpResponsePromise_js_1.HttpResponsePromise; } });
|
|
12
|
+
var makePassthroughRequest_js_1 = require("./makePassthroughRequest.js");
|
|
13
|
+
Object.defineProperty(exports, "makePassthroughRequest", { enumerable: true, get: function () { return makePassthroughRequest_js_1.makePassthroughRequest; } });
|
|
12
14
|
var RawResponse_js_1 = require("./RawResponse.js");
|
|
13
15
|
Object.defineProperty(exports, "abortRawResponse", { enumerable: true, get: function () { return RawResponse_js_1.abortRawResponse; } });
|
|
14
16
|
Object.defineProperty(exports, "toRawResponse", { enumerable: true, get: function () { return RawResponse_js_1.toRawResponse; } });
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { type LogConfig, type Logger } from "../logging/logger.js";
|
|
2
|
+
import { Supplier } from "./Supplier.js";
|
|
3
|
+
export declare namespace PassthroughRequest {
|
|
4
|
+
/**
|
|
5
|
+
* Per-request options that can override the SDK client defaults.
|
|
6
|
+
*/
|
|
7
|
+
interface RequestOptions {
|
|
8
|
+
/** Override the default timeout for this request (in seconds). */
|
|
9
|
+
timeoutInSeconds?: number;
|
|
10
|
+
/** Override the default number of retries for this request. */
|
|
11
|
+
maxRetries?: number;
|
|
12
|
+
/** Additional headers to include in this request. */
|
|
13
|
+
headers?: Record<string, string>;
|
|
14
|
+
/** Abort signal for this request. */
|
|
15
|
+
abortSignal?: AbortSignal;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* SDK client configuration used by the passthrough fetch method.
|
|
19
|
+
*/
|
|
20
|
+
interface ClientOptions {
|
|
21
|
+
/** The base URL or environment for the client. */
|
|
22
|
+
environment?: Supplier<string>;
|
|
23
|
+
/** Override the base URL. */
|
|
24
|
+
baseUrl?: Supplier<string>;
|
|
25
|
+
/** Default headers to include in requests. */
|
|
26
|
+
headers?: Record<string, unknown>;
|
|
27
|
+
/** Default maximum time to wait for a response in seconds. */
|
|
28
|
+
timeoutInSeconds?: number;
|
|
29
|
+
/** Default number of times to retry the request. Defaults to 2. */
|
|
30
|
+
maxRetries?: number;
|
|
31
|
+
/** A custom fetch function. */
|
|
32
|
+
fetch?: typeof fetch;
|
|
33
|
+
/** Logging configuration. */
|
|
34
|
+
logging?: LogConfig | Logger;
|
|
35
|
+
/** A function that returns auth headers. */
|
|
36
|
+
getAuthHeaders?: () => Promise<Record<string, string>>;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Makes a passthrough HTTP request using the SDK's configuration (auth, retry, logging, etc.)
|
|
41
|
+
* while mimicking the standard `fetch` API.
|
|
42
|
+
*
|
|
43
|
+
* @param input - The URL, path, or Request object. If a relative path, it will be resolved against the configured base URL.
|
|
44
|
+
* @param init - Standard RequestInit options (method, headers, body, signal, etc.)
|
|
45
|
+
* @param clientOptions - SDK client options (auth, default headers, logging, etc.)
|
|
46
|
+
* @param requestOptions - Per-request overrides (timeout, retries, extra headers, abort signal).
|
|
47
|
+
* @returns A standard Response object.
|
|
48
|
+
*/
|
|
49
|
+
export declare function makePassthroughRequest(input: Request | string | URL, init: RequestInit | undefined, clientOptions: PassthroughRequest.ClientOptions, requestOptions?: PassthroughRequest.RequestOptions): Promise<Response>;
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.makePassthroughRequest = makePassthroughRequest;
|
|
13
|
+
const logger_js_1 = require("../logging/logger.js");
|
|
14
|
+
const join_js_1 = require("../url/join.js");
|
|
15
|
+
const EndpointSupplier_js_1 = require("./EndpointSupplier.js");
|
|
16
|
+
const getFetchFn_js_1 = require("./getFetchFn.js");
|
|
17
|
+
const makeRequest_js_1 = require("./makeRequest.js");
|
|
18
|
+
const requestWithRetries_js_1 = require("./requestWithRetries.js");
|
|
19
|
+
const Supplier_js_1 = require("./Supplier.js");
|
|
20
|
+
/**
|
|
21
|
+
* Makes a passthrough HTTP request using the SDK's configuration (auth, retry, logging, etc.)
|
|
22
|
+
* while mimicking the standard `fetch` API.
|
|
23
|
+
*
|
|
24
|
+
* @param input - The URL, path, or Request object. If a relative path, it will be resolved against the configured base URL.
|
|
25
|
+
* @param init - Standard RequestInit options (method, headers, body, signal, etc.)
|
|
26
|
+
* @param clientOptions - SDK client options (auth, default headers, logging, etc.)
|
|
27
|
+
* @param requestOptions - Per-request overrides (timeout, retries, extra headers, abort signal).
|
|
28
|
+
* @returns A standard Response object.
|
|
29
|
+
*/
|
|
30
|
+
function makePassthroughRequest(input, init, clientOptions, requestOptions) {
|
|
31
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
33
|
+
const logger = (0, logger_js_1.createLogger)(clientOptions.logging);
|
|
34
|
+
// Extract URL and default init properties from Request object if provided
|
|
35
|
+
let url;
|
|
36
|
+
let effectiveInit = init;
|
|
37
|
+
if (input instanceof Request) {
|
|
38
|
+
url = input.url;
|
|
39
|
+
// If no explicit init provided, extract properties from the Request object
|
|
40
|
+
if (init == null) {
|
|
41
|
+
effectiveInit = {
|
|
42
|
+
method: input.method,
|
|
43
|
+
headers: Object.fromEntries(input.headers.entries()),
|
|
44
|
+
body: input.body,
|
|
45
|
+
signal: input.signal,
|
|
46
|
+
credentials: input.credentials,
|
|
47
|
+
cache: input.cache,
|
|
48
|
+
redirect: input.redirect,
|
|
49
|
+
referrer: input.referrer,
|
|
50
|
+
integrity: input.integrity,
|
|
51
|
+
mode: input.mode,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
url = input instanceof URL ? input.toString() : input;
|
|
57
|
+
}
|
|
58
|
+
// Resolve the base URL
|
|
59
|
+
const baseUrl = (_a = (clientOptions.baseUrl != null ? yield Supplier_js_1.Supplier.get(clientOptions.baseUrl) : undefined)) !== null && _a !== void 0 ? _a : (clientOptions.environment != null ? yield Supplier_js_1.Supplier.get(clientOptions.environment) : undefined);
|
|
60
|
+
// Determine the full URL
|
|
61
|
+
let fullUrl;
|
|
62
|
+
if (url.startsWith("http://") || url.startsWith("https://")) {
|
|
63
|
+
fullUrl = url;
|
|
64
|
+
}
|
|
65
|
+
else if (baseUrl != null) {
|
|
66
|
+
fullUrl = (0, join_js_1.join)(baseUrl, url);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
fullUrl = url;
|
|
70
|
+
}
|
|
71
|
+
// Merge headers: SDK default headers -> auth headers -> user-provided headers
|
|
72
|
+
const mergedHeaders = {};
|
|
73
|
+
// Apply SDK default headers (resolve suppliers)
|
|
74
|
+
if (clientOptions.headers != null) {
|
|
75
|
+
for (const [key, value] of Object.entries(clientOptions.headers)) {
|
|
76
|
+
const resolved = yield EndpointSupplier_js_1.EndpointSupplier.get(value, { endpointMetadata: {} });
|
|
77
|
+
if (resolved != null) {
|
|
78
|
+
mergedHeaders[key.toLowerCase()] = `${resolved}`;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
// Apply auth headers
|
|
83
|
+
if (clientOptions.getAuthHeaders != null) {
|
|
84
|
+
const authHeaders = yield clientOptions.getAuthHeaders();
|
|
85
|
+
for (const [key, value] of Object.entries(authHeaders)) {
|
|
86
|
+
mergedHeaders[key.toLowerCase()] = value;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
// Apply user-provided headers from init
|
|
90
|
+
if ((effectiveInit === null || effectiveInit === void 0 ? void 0 : effectiveInit.headers) != null) {
|
|
91
|
+
const initHeaders = effectiveInit.headers instanceof Headers
|
|
92
|
+
? Object.fromEntries(effectiveInit.headers.entries())
|
|
93
|
+
: Array.isArray(effectiveInit.headers)
|
|
94
|
+
? Object.fromEntries(effectiveInit.headers)
|
|
95
|
+
: effectiveInit.headers;
|
|
96
|
+
for (const [key, value] of Object.entries(initHeaders)) {
|
|
97
|
+
if (value != null) {
|
|
98
|
+
mergedHeaders[key.toLowerCase()] = value;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
// Apply per-request option headers (highest priority)
|
|
103
|
+
if ((requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers) != null) {
|
|
104
|
+
for (const [key, value] of Object.entries(requestOptions.headers)) {
|
|
105
|
+
mergedHeaders[key.toLowerCase()] = value;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
const method = (_b = effectiveInit === null || effectiveInit === void 0 ? void 0 : effectiveInit.method) !== null && _b !== void 0 ? _b : "GET";
|
|
109
|
+
const body = effectiveInit === null || effectiveInit === void 0 ? void 0 : effectiveInit.body;
|
|
110
|
+
const timeoutInSeconds = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _c !== void 0 ? _c : clientOptions.timeoutInSeconds;
|
|
111
|
+
const timeoutMs = timeoutInSeconds != null ? timeoutInSeconds * 1000 : undefined;
|
|
112
|
+
const maxRetries = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _d !== void 0 ? _d : clientOptions.maxRetries;
|
|
113
|
+
const abortSignal = (_f = (_e = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal) !== null && _e !== void 0 ? _e : effectiveInit === null || effectiveInit === void 0 ? void 0 : effectiveInit.signal) !== null && _f !== void 0 ? _f : undefined;
|
|
114
|
+
const fetchFn = (_g = clientOptions.fetch) !== null && _g !== void 0 ? _g : (yield (0, getFetchFn_js_1.getFetchFn)());
|
|
115
|
+
if (logger.isDebug()) {
|
|
116
|
+
logger.debug("Making passthrough HTTP request", {
|
|
117
|
+
method,
|
|
118
|
+
url: fullUrl,
|
|
119
|
+
hasBody: body != null,
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
const response = yield (0, requestWithRetries_js_1.requestWithRetries)(() => __awaiter(this, void 0, void 0, function* () {
|
|
123
|
+
return (0, makeRequest_js_1.makeRequest)(fetchFn, fullUrl, method, mergedHeaders, body !== null && body !== void 0 ? body : undefined, timeoutMs, abortSignal, (effectiveInit === null || effectiveInit === void 0 ? void 0 : effectiveInit.credentials) === "include", undefined, // duplex
|
|
124
|
+
false);
|
|
125
|
+
}), maxRetries);
|
|
126
|
+
if (logger.isDebug()) {
|
|
127
|
+
logger.debug("Passthrough HTTP request completed", {
|
|
128
|
+
method,
|
|
129
|
+
url: fullUrl,
|
|
130
|
+
statusCode: response.status,
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
return response;
|
|
134
|
+
});
|
|
135
|
+
}
|
|
@@ -1 +1,6 @@
|
|
|
1
|
-
export declare
|
|
1
|
+
export declare function isCacheNoStoreSupported(): boolean;
|
|
2
|
+
/**
|
|
3
|
+
* Reset the cached result of `isCacheNoStoreSupported`. Exposed for testing only.
|
|
4
|
+
*/
|
|
5
|
+
export declare function resetCacheNoStoreSupported(): void;
|
|
6
|
+
export declare const makeRequest: (fetchFn: (url: string, init: RequestInit) => Promise<Response>, url: string, method: string, headers: Headers | Record<string, string>, requestBody: BodyInit | undefined, timeoutMs?: number, abortSignal?: AbortSignal, withCredentials?: boolean, duplex?: "half", disableCache?: boolean) => Promise<Response>;
|
|
@@ -10,8 +10,35 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.makeRequest = void 0;
|
|
13
|
+
exports.isCacheNoStoreSupported = isCacheNoStoreSupported;
|
|
14
|
+
exports.resetCacheNoStoreSupported = resetCacheNoStoreSupported;
|
|
13
15
|
const signals_js_1 = require("./signals.js");
|
|
14
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Cached result of checking whether the current runtime supports
|
|
18
|
+
* the `cache` option in `Request`. Some runtimes (e.g. Cloudflare Workers)
|
|
19
|
+
* throw a TypeError when this option is used.
|
|
20
|
+
*/
|
|
21
|
+
let _cacheNoStoreSupported;
|
|
22
|
+
function isCacheNoStoreSupported() {
|
|
23
|
+
if (_cacheNoStoreSupported != null) {
|
|
24
|
+
return _cacheNoStoreSupported;
|
|
25
|
+
}
|
|
26
|
+
try {
|
|
27
|
+
new Request("http://localhost", { cache: "no-store" });
|
|
28
|
+
_cacheNoStoreSupported = true;
|
|
29
|
+
}
|
|
30
|
+
catch (_a) {
|
|
31
|
+
_cacheNoStoreSupported = false;
|
|
32
|
+
}
|
|
33
|
+
return _cacheNoStoreSupported;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Reset the cached result of `isCacheNoStoreSupported`. Exposed for testing only.
|
|
37
|
+
*/
|
|
38
|
+
function resetCacheNoStoreSupported() {
|
|
39
|
+
_cacheNoStoreSupported = undefined;
|
|
40
|
+
}
|
|
41
|
+
const makeRequest = (fetchFn, url, method, headers, requestBody, timeoutMs, abortSignal, withCredentials, duplex, disableCache) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
42
|
const signals = [];
|
|
16
43
|
let timeoutAbortId;
|
|
17
44
|
if (timeoutMs != null) {
|
|
@@ -23,15 +50,9 @@ const makeRequest = (fetchFn, url, method, headers, requestBody, timeoutMs, abor
|
|
|
23
50
|
signals.push(abortSignal);
|
|
24
51
|
}
|
|
25
52
|
const newSignals = (0, signals_js_1.anySignal)(signals);
|
|
26
|
-
const response = yield fetchFn(url, {
|
|
27
|
-
method: method,
|
|
28
|
-
headers,
|
|
29
|
-
body: requestBody,
|
|
30
|
-
signal: newSignals,
|
|
31
|
-
credentials: withCredentials ? "include" : undefined,
|
|
53
|
+
const response = yield fetchFn(url, Object.assign({ method: method, headers, body: requestBody, signal: newSignals, credentials: withCredentials ? "include" : undefined,
|
|
32
54
|
// @ts-ignore
|
|
33
|
-
duplex,
|
|
34
|
-
});
|
|
55
|
+
duplex }, (disableCache && isCacheNoStoreSupported() ? { cache: "no-store" } : {})));
|
|
35
56
|
if (timeoutAbortId != null) {
|
|
36
57
|
clearTimeout(timeoutAbortId);
|
|
37
58
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function mergeHeaders
|
|
2
|
-
export declare function mergeOnlyDefinedHeaders
|
|
1
|
+
export declare function mergeHeaders(...headersArray: (Record<string, unknown> | null | undefined)[]): Record<string, unknown>;
|
|
2
|
+
export declare function mergeOnlyDefinedHeaders(...headersArray: (Record<string, unknown> | null | undefined)[]): Record<string, unknown>;
|
|
@@ -84,17 +84,18 @@ function evaluateRuntime() {
|
|
|
84
84
|
}
|
|
85
85
|
/**
|
|
86
86
|
* A constant that indicates whether the environment the code is running is Node.JS.
|
|
87
|
+
*
|
|
88
|
+
* We assign `process` to a local variable first to avoid being flagged by
|
|
89
|
+
* bundlers that perform static analysis on `process.versions` (e.g. Next.js
|
|
90
|
+
* Edge Runtime warns about Node.js APIs even when they are guarded).
|
|
87
91
|
*/
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
!!process.version &&
|
|
91
|
-
"versions" in process &&
|
|
92
|
-
!!((_e = process.versions) === null || _e === void 0 ? void 0 : _e.node);
|
|
92
|
+
const _process = typeof process !== "undefined" ? process : undefined;
|
|
93
|
+
const isNode = typeof _process !== "undefined" && typeof ((_e = _process.versions) === null || _e === void 0 ? void 0 : _e.node) === "string";
|
|
93
94
|
if (isNode) {
|
|
94
95
|
return {
|
|
95
96
|
type: "node",
|
|
96
|
-
version:
|
|
97
|
-
parsedVersion: Number(
|
|
97
|
+
version: _process.versions.node,
|
|
98
|
+
parsedVersion: Number(_process.versions.node.split(".")[0]),
|
|
98
99
|
};
|
|
99
100
|
}
|
|
100
101
|
return {
|
|
@@ -3,10 +3,12 @@ export declare class KardApiError extends Error {
|
|
|
3
3
|
readonly statusCode?: number;
|
|
4
4
|
readonly body?: unknown;
|
|
5
5
|
readonly rawResponse?: core.RawResponse;
|
|
6
|
-
|
|
6
|
+
readonly cause?: unknown;
|
|
7
|
+
constructor({ message, statusCode, body, rawResponse, cause, }: {
|
|
7
8
|
message?: string;
|
|
8
9
|
statusCode?: number;
|
|
9
10
|
body?: unknown;
|
|
10
11
|
rawResponse?: core.RawResponse;
|
|
12
|
+
cause?: unknown;
|
|
11
13
|
});
|
|
12
14
|
}
|
|
@@ -4,12 +4,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
exports.KardApiError = void 0;
|
|
5
5
|
const json_js_1 = require("../core/json.js");
|
|
6
6
|
class KardApiError extends Error {
|
|
7
|
-
constructor({ message, statusCode, body, rawResponse, }) {
|
|
7
|
+
constructor({ message, statusCode, body, rawResponse, cause, }) {
|
|
8
8
|
super(buildMessage({ message, statusCode, body }));
|
|
9
|
-
Object.setPrototypeOf(this,
|
|
9
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
10
|
+
if (Error.captureStackTrace) {
|
|
11
|
+
Error.captureStackTrace(this, this.constructor);
|
|
12
|
+
}
|
|
13
|
+
this.name = this.constructor.name;
|
|
10
14
|
this.statusCode = statusCode;
|
|
11
15
|
this.body = body;
|
|
12
16
|
this.rawResponse = rawResponse;
|
|
17
|
+
if (cause != null) {
|
|
18
|
+
this.cause = cause;
|
|
19
|
+
}
|
|
13
20
|
}
|
|
14
21
|
}
|
|
15
22
|
exports.KardApiError = KardApiError;
|
|
@@ -3,9 +3,16 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.KardApiTimeoutError = void 0;
|
|
5
5
|
class KardApiTimeoutError extends Error {
|
|
6
|
-
constructor(message) {
|
|
6
|
+
constructor(message, opts) {
|
|
7
7
|
super(message);
|
|
8
|
-
Object.setPrototypeOf(this,
|
|
8
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
9
|
+
if (Error.captureStackTrace) {
|
|
10
|
+
Error.captureStackTrace(this, this.constructor);
|
|
11
|
+
}
|
|
12
|
+
this.name = this.constructor.name;
|
|
13
|
+
if ((opts === null || opts === void 0 ? void 0 : opts.cause) != null) {
|
|
14
|
+
this.cause = opts.cause;
|
|
15
|
+
}
|
|
9
16
|
}
|
|
10
17
|
}
|
|
11
18
|
exports.KardApiTimeoutError = KardApiTimeoutError;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// This file was auto-generated by Fern from our API Definition.
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
exports.handleNonStatusCodeError = handleNonStatusCodeError;
|
|
38
|
+
const errors = __importStar(require("./index.js"));
|
|
39
|
+
function handleNonStatusCodeError(error, rawResponse, method, path) {
|
|
40
|
+
switch (error.reason) {
|
|
41
|
+
case "non-json":
|
|
42
|
+
throw new errors.KardApiError({
|
|
43
|
+
statusCode: error.statusCode,
|
|
44
|
+
body: error.rawBody,
|
|
45
|
+
rawResponse: rawResponse,
|
|
46
|
+
});
|
|
47
|
+
case "body-is-null":
|
|
48
|
+
throw new errors.KardApiError({
|
|
49
|
+
statusCode: error.statusCode,
|
|
50
|
+
rawResponse: rawResponse,
|
|
51
|
+
});
|
|
52
|
+
case "timeout":
|
|
53
|
+
throw new errors.KardApiTimeoutError(`Timeout exceeded when calling ${method} ${path}.`, {
|
|
54
|
+
cause: error.cause,
|
|
55
|
+
});
|
|
56
|
+
case "unknown":
|
|
57
|
+
throw new errors.KardApiError({
|
|
58
|
+
message: error.errorMessage,
|
|
59
|
+
rawResponse: rawResponse,
|
|
60
|
+
cause: error.cause,
|
|
61
|
+
});
|
|
62
|
+
default:
|
|
63
|
+
throw new errors.KardApiError({
|
|
64
|
+
message: "Unknown error",
|
|
65
|
+
rawResponse: rawResponse,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
package/dist/cjs/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "
|
|
1
|
+
export declare const SDK_VERSION = "13.0.0";
|
package/dist/cjs/version.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
+
import { OAuthAuthProvider } from "./auth/OAuthAuthProvider.mjs";
|
|
1
2
|
import * as core from "./core/index.mjs";
|
|
2
3
|
import type * as environments from "./environments.mjs";
|
|
3
|
-
export
|
|
4
|
+
export type BaseClientOptions = {
|
|
4
5
|
environment?: core.Supplier<environments.KardApiEnvironment | string>;
|
|
5
6
|
/** Specify a custom URL to connect the client to. */
|
|
6
7
|
baseUrl?: core.Supplier<string>;
|
|
7
|
-
clientId?: core.Supplier<string>;
|
|
8
|
-
clientSecret?: core.Supplier<string>;
|
|
9
8
|
/** Additional headers to include in requests. */
|
|
10
9
|
headers?: Record<string, string | core.Supplier<string | null | undefined> | null | undefined>;
|
|
11
10
|
/** The default maximum time to wait for a response in seconds. */
|
|
@@ -16,7 +15,7 @@ export interface BaseClientOptions {
|
|
|
16
15
|
fetch?: typeof fetch;
|
|
17
16
|
/** Configure logging for the client. */
|
|
18
17
|
logging?: core.logging.LogConfig | core.logging.Logger;
|
|
19
|
-
}
|
|
18
|
+
} & OAuthAuthProvider.AuthOptions;
|
|
20
19
|
export interface BaseRequestOptions {
|
|
21
20
|
/** The maximum time to wait for a response in seconds. */
|
|
22
21
|
timeoutInSeconds?: number;
|
|
@@ -29,12 +28,12 @@ export interface BaseRequestOptions {
|
|
|
29
28
|
/** Additional headers to include in the request. */
|
|
30
29
|
headers?: Record<string, string | core.Supplier<string | null | undefined> | null | undefined>;
|
|
31
30
|
}
|
|
32
|
-
export type NormalizedClientOptions<T extends BaseClientOptions> = T & {
|
|
31
|
+
export type NormalizedClientOptions<T extends BaseClientOptions = BaseClientOptions> = T & {
|
|
33
32
|
logging: core.logging.Logger;
|
|
34
33
|
authProvider?: core.AuthProvider;
|
|
35
34
|
};
|
|
36
|
-
export type NormalizedClientOptionsWithAuth<T extends BaseClientOptions> = NormalizedClientOptions<T> & {
|
|
35
|
+
export type NormalizedClientOptionsWithAuth<T extends BaseClientOptions = BaseClientOptions> = NormalizedClientOptions<T> & {
|
|
37
36
|
authProvider: core.AuthProvider;
|
|
38
37
|
};
|
|
39
|
-
export declare function normalizeClientOptions<T extends BaseClientOptions>(options: T): NormalizedClientOptions<T>;
|
|
40
|
-
export declare function normalizeClientOptionsWithAuth<T extends BaseClientOptions>(options: T): NormalizedClientOptionsWithAuth<T>;
|
|
38
|
+
export declare function normalizeClientOptions<T extends BaseClientOptions = BaseClientOptions>(options: T): NormalizedClientOptions<T>;
|
|
39
|
+
export declare function normalizeClientOptionsWithAuth<T extends BaseClientOptions = BaseClientOptions>(options: T): NormalizedClientOptionsWithAuth<T>;
|
package/dist/esm/BaseClient.mjs
CHANGED
|
@@ -6,8 +6,8 @@ export function normalizeClientOptions(options) {
|
|
|
6
6
|
const headers = mergeHeaders({
|
|
7
7
|
"X-Fern-Language": "JavaScript",
|
|
8
8
|
"X-Fern-SDK-Name": "@kard-financial/sdk",
|
|
9
|
-
"X-Fern-SDK-Version": "
|
|
10
|
-
"User-Agent": "@kard-financial/sdk/
|
|
9
|
+
"X-Fern-SDK-Version": "13.0.0",
|
|
10
|
+
"User-Agent": "@kard-financial/sdk/13.0.0",
|
|
11
11
|
"X-Fern-Runtime": core.RUNTIME.type,
|
|
12
12
|
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
13
13
|
}, options === null || options === void 0 ? void 0 : options.headers);
|
|
@@ -17,7 +17,7 @@ export function normalizeClientOptionsWithAuth(options) {
|
|
|
17
17
|
var _a;
|
|
18
18
|
const normalized = normalizeClientOptions(options);
|
|
19
19
|
const normalizedWithNoOpAuthProvider = withNoOpAuthProvider(normalized);
|
|
20
|
-
(_a = normalized.authProvider) !== null && _a !== void 0 ? _a : (normalized.authProvider =
|
|
20
|
+
(_a = normalized.authProvider) !== null && _a !== void 0 ? _a : (normalized.authProvider = OAuthAuthProvider.createInstance(normalizedWithNoOpAuthProvider));
|
|
21
21
|
return normalized;
|
|
22
22
|
}
|
|
23
23
|
function withNoOpAuthProvider(options) {
|
package/dist/esm/Client.d.mts
CHANGED
|
@@ -6,9 +6,9 @@ import { TransactionsClient } from "./api/resources/transactions/client/Client.m
|
|
|
6
6
|
import { UsersClient } from "./api/resources/users/client/Client.mjs";
|
|
7
7
|
import type { BaseClientOptions, BaseRequestOptions } from "./BaseClient.mjs";
|
|
8
8
|
import { type NormalizedClientOptionsWithAuth } from "./BaseClient.mjs";
|
|
9
|
+
import * as core from "./core/index.mjs";
|
|
9
10
|
export declare namespace KardApiClient {
|
|
10
|
-
|
|
11
|
-
}
|
|
11
|
+
type Options = BaseClientOptions;
|
|
12
12
|
interface RequestOptions extends BaseRequestOptions {
|
|
13
13
|
}
|
|
14
14
|
}
|
|
@@ -27,4 +27,15 @@ export declare class KardApiClient {
|
|
|
27
27
|
get ping(): PingClient;
|
|
28
28
|
get transactions(): TransactionsClient;
|
|
29
29
|
get users(): UsersClient;
|
|
30
|
+
/**
|
|
31
|
+
* Make a passthrough request using the SDK's configured auth, retry, logging, etc.
|
|
32
|
+
* This is useful for making requests to endpoints not yet supported in the SDK.
|
|
33
|
+
* The input can be a URL string, URL object, or Request object. Relative paths are resolved against the configured base URL.
|
|
34
|
+
*
|
|
35
|
+
* @param {Request | string | URL} input - The URL, path, or Request object.
|
|
36
|
+
* @param {RequestInit} init - Standard fetch RequestInit options.
|
|
37
|
+
* @param {core.PassthroughRequest.RequestOptions} requestOptions - Per-request overrides (timeout, retries, headers, abort signal).
|
|
38
|
+
* @returns {Promise<Response>} A standard Response object.
|
|
39
|
+
*/
|
|
40
|
+
fetch(input: Request | string | URL, init?: RequestInit, requestOptions?: core.PassthroughRequest.RequestOptions): Promise<Response>;
|
|
30
41
|
}
|