@kard-financial/sdk 12.2.1 → 12.4.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 +15 -112
- package/dist/cjs/api/resources/transactions/client/requests/GetEarnedRewardsRequest.d.ts +4 -1
- 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/GetEarnedRewardsResponse.d.ts +1 -1
- 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/TransactionsAttributes.d.ts +18 -18
- 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 +15 -112
- package/dist/esm/api/resources/transactions/client/requests/GetEarnedRewardsRequest.d.mts +4 -1
- 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/GetEarnedRewardsResponse.d.mts +1 -1
- 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/TransactionsAttributes.d.mts +18 -18
- 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
|
@@ -4,7 +4,7 @@ import type * as KardApi from "../../../../../index.mjs";
|
|
|
4
4
|
*/
|
|
5
5
|
export interface ProgressBarLabels {
|
|
6
6
|
/** Label configuration for the details view */
|
|
7
|
-
details?: KardApi.users.ProgressBarLabelPair;
|
|
7
|
+
details?: KardApi.users.ProgressBarLabelPair | undefined;
|
|
8
8
|
/** Label configuration for the default view */
|
|
9
9
|
default: KardApi.users.ProgressBarLabelPair;
|
|
10
10
|
}
|
|
@@ -4,7 +4,7 @@ import type * as KardApi from "../../../../../index.mjs";
|
|
|
4
4
|
*/
|
|
5
5
|
export interface ProgressBarSegment {
|
|
6
6
|
/** SVG icon to use for each segment */
|
|
7
|
-
icon?: string;
|
|
7
|
+
icon?: string | undefined;
|
|
8
8
|
/** Position of the segment within the layout */
|
|
9
9
|
position: KardApi.users.ProgressBarSegmentPosition;
|
|
10
10
|
}
|
|
@@ -4,7 +4,7 @@ import type * as KardApi from "../../../../../index.mjs";
|
|
|
4
4
|
*/
|
|
5
5
|
export interface ProgressBarSegments {
|
|
6
6
|
/** Segment configuration for the details view */
|
|
7
|
-
details?: KardApi.users.ProgressBarSegment;
|
|
7
|
+
details?: KardApi.users.ProgressBarSegment | undefined;
|
|
8
8
|
/** Segment configuration for the default view */
|
|
9
9
|
default: KardApi.users.ProgressBarSegment;
|
|
10
10
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type * as KardApi from "../../../../../index.mjs";
|
|
2
2
|
export interface StandardOffer extends KardApi.users.StandardOfferCore {
|
|
3
|
-
relationships?: KardApi.users.EligibilityOfferRelationship;
|
|
3
|
+
relationships?: KardApi.users.EligibilityOfferRelationship | undefined;
|
|
4
4
|
}
|
|
@@ -3,8 +3,7 @@ import { type NormalizedClientOptionsWithAuth } from "../../../../../../BaseClie
|
|
|
3
3
|
import * as core from "../../../../../../core/index.mjs";
|
|
4
4
|
import * as KardApi from "../../../../../index.mjs";
|
|
5
5
|
export declare namespace UploadsClient {
|
|
6
|
-
|
|
7
|
-
}
|
|
6
|
+
type Options = BaseClientOptions;
|
|
8
7
|
interface RequestOptions extends BaseRequestOptions {
|
|
9
8
|
}
|
|
10
9
|
}
|
|
@@ -12,6 +12,7 @@ import { normalizeClientOptionsWithAuth } from "../../../../../../BaseClient.mjs
|
|
|
12
12
|
import { mergeHeaders } from "../../../../../../core/headers.mjs";
|
|
13
13
|
import * as core from "../../../../../../core/index.mjs";
|
|
14
14
|
import * as environments from "../../../../../../environments.mjs";
|
|
15
|
+
import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.mjs";
|
|
15
16
|
import * as errors from "../../../../../../errors/index.mjs";
|
|
16
17
|
import * as KardApi from "../../../../../index.mjs";
|
|
17
18
|
export class UploadsClient {
|
|
@@ -84,26 +85,7 @@ export class UploadsClient {
|
|
|
84
85
|
});
|
|
85
86
|
}
|
|
86
87
|
}
|
|
87
|
-
|
|
88
|
-
case "non-json":
|
|
89
|
-
throw new errors.KardApiError({
|
|
90
|
-
statusCode: _response.error.statusCode,
|
|
91
|
-
body: _response.error.rawBody,
|
|
92
|
-
rawResponse: _response.rawResponse,
|
|
93
|
-
});
|
|
94
|
-
case "body-is-null":
|
|
95
|
-
throw new errors.KardApiError({
|
|
96
|
-
statusCode: _response.error.statusCode,
|
|
97
|
-
rawResponse: _response.rawResponse,
|
|
98
|
-
});
|
|
99
|
-
case "timeout":
|
|
100
|
-
throw new errors.KardApiTimeoutError("Timeout exceeded when calling POST /v2/issuers/{organizationId}/users/{userId}/uploads.");
|
|
101
|
-
case "unknown":
|
|
102
|
-
throw new errors.KardApiError({
|
|
103
|
-
message: _response.error.errorMessage,
|
|
104
|
-
rawResponse: _response.rawResponse,
|
|
105
|
-
});
|
|
106
|
-
}
|
|
88
|
+
return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v2/issuers/{organizationId}/users/{userId}/uploads");
|
|
107
89
|
});
|
|
108
90
|
}
|
|
109
91
|
/**
|
|
@@ -208,26 +190,7 @@ export class UploadsClient {
|
|
|
208
190
|
});
|
|
209
191
|
}
|
|
210
192
|
}
|
|
211
|
-
|
|
212
|
-
case "non-json":
|
|
213
|
-
throw new errors.KardApiError({
|
|
214
|
-
statusCode: _response.error.statusCode,
|
|
215
|
-
body: _response.error.rawBody,
|
|
216
|
-
rawResponse: _response.rawResponse,
|
|
217
|
-
});
|
|
218
|
-
case "body-is-null":
|
|
219
|
-
throw new errors.KardApiError({
|
|
220
|
-
statusCode: _response.error.statusCode,
|
|
221
|
-
rawResponse: _response.rawResponse,
|
|
222
|
-
});
|
|
223
|
-
case "timeout":
|
|
224
|
-
throw new errors.KardApiTimeoutError("Timeout exceeded when calling PUT /v2/issuers/{organizationId}/users/{userId}/uploads/{uploadId}/parts.");
|
|
225
|
-
case "unknown":
|
|
226
|
-
throw new errors.KardApiError({
|
|
227
|
-
message: _response.error.errorMessage,
|
|
228
|
-
rawResponse: _response.rawResponse,
|
|
229
|
-
});
|
|
230
|
-
}
|
|
193
|
+
return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/v2/issuers/{organizationId}/users/{userId}/uploads/{uploadId}/parts");
|
|
231
194
|
});
|
|
232
195
|
}
|
|
233
196
|
/**
|
|
@@ -300,26 +263,7 @@ export class UploadsClient {
|
|
|
300
263
|
});
|
|
301
264
|
}
|
|
302
265
|
}
|
|
303
|
-
|
|
304
|
-
case "non-json":
|
|
305
|
-
throw new errors.KardApiError({
|
|
306
|
-
statusCode: _response.error.statusCode,
|
|
307
|
-
body: _response.error.rawBody,
|
|
308
|
-
rawResponse: _response.rawResponse,
|
|
309
|
-
});
|
|
310
|
-
case "body-is-null":
|
|
311
|
-
throw new errors.KardApiError({
|
|
312
|
-
statusCode: _response.error.statusCode,
|
|
313
|
-
rawResponse: _response.rawResponse,
|
|
314
|
-
});
|
|
315
|
-
case "timeout":
|
|
316
|
-
throw new errors.KardApiTimeoutError("Timeout exceeded when calling PUT /v2/issuers/{organizationId}/users/{userId}/uploads/{uploadId}.");
|
|
317
|
-
case "unknown":
|
|
318
|
-
throw new errors.KardApiError({
|
|
319
|
-
message: _response.error.errorMessage,
|
|
320
|
-
rawResponse: _response.rawResponse,
|
|
321
|
-
});
|
|
322
|
-
}
|
|
266
|
+
return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/v2/issuers/{organizationId}/users/{userId}/uploads/{uploadId}");
|
|
323
267
|
});
|
|
324
268
|
}
|
|
325
269
|
}
|
|
@@ -8,6 +8,10 @@ export class UploadPartMultiStatus extends errors.KardApiError {
|
|
|
8
8
|
body: body,
|
|
9
9
|
rawResponse: rawResponse,
|
|
10
10
|
});
|
|
11
|
-
Object.setPrototypeOf(this,
|
|
11
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
12
|
+
if (Error.captureStackTrace) {
|
|
13
|
+
Error.captureStackTrace(this, this.constructor);
|
|
14
|
+
}
|
|
15
|
+
this.name = this.constructor.name;
|
|
12
16
|
}
|
|
13
17
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type * as KardApi from "../../../../../index.mjs";
|
|
2
2
|
export interface CreateUploadPartMultiStatusResponse extends KardApi.ErrorResponse {
|
|
3
|
-
data?: KardApi.users.CreateUploadPartResponseDataUnion[];
|
|
3
|
+
data?: KardApi.users.CreateUploadPartResponseDataUnion[] | undefined;
|
|
4
4
|
}
|
|
@@ -3,13 +3,13 @@ export interface UpdateUserRequestAttributes {
|
|
|
3
3
|
/** Rewards programs to enroll the user in. If an empty array is supplied, the user will not be enrolled in any programs. */
|
|
4
4
|
enrolledRewards: KardApi.EnrolledRewardsType[];
|
|
5
5
|
/** Zipcode of user */
|
|
6
|
-
zipCode?: string;
|
|
6
|
+
zipCode?: string | undefined;
|
|
7
7
|
/** Email address of user */
|
|
8
|
-
email?: string;
|
|
8
|
+
email?: string | undefined;
|
|
9
9
|
/** Hashed email address of user (using SHA-256) */
|
|
10
|
-
hashedEmail?: string;
|
|
10
|
+
hashedEmail?: string | undefined;
|
|
11
11
|
/** Phone number of user in E.164 format */
|
|
12
|
-
phoneNumber?: string;
|
|
12
|
+
phoneNumber?: string | undefined;
|
|
13
13
|
/** Birth year of user */
|
|
14
|
-
birthYear?: string;
|
|
14
|
+
birthYear?: string | undefined;
|
|
15
15
|
}
|
|
@@ -3,15 +3,15 @@ export interface UserRequestAttributes {
|
|
|
3
3
|
/** Rewards programs to enroll the user in. If an empty array is supplied, the user will not be enrolled in any programs. */
|
|
4
4
|
enrolledRewards: KardApi.EnrolledRewardsType[];
|
|
5
5
|
/** Zipcode of user */
|
|
6
|
-
zipCode?: string;
|
|
6
|
+
zipCode?: string | undefined;
|
|
7
7
|
/** Email address of user */
|
|
8
|
-
email?: string;
|
|
8
|
+
email?: string | undefined;
|
|
9
9
|
/** Hashed email address of user (using SHA-256) */
|
|
10
|
-
hashedEmail?: string;
|
|
10
|
+
hashedEmail?: string | undefined;
|
|
11
11
|
/** Phone number of user in E.164 format */
|
|
12
|
-
phoneNumber?: string;
|
|
12
|
+
phoneNumber?: string | undefined;
|
|
13
13
|
/** Birth year of user */
|
|
14
|
-
birthYear?: string;
|
|
14
|
+
birthYear?: string | undefined;
|
|
15
15
|
/** Indicates whether historical transactions have been sent for this user */
|
|
16
|
-
historicalTransactionsSent?: boolean;
|
|
16
|
+
historicalTransactionsSent?: boolean | undefined;
|
|
17
17
|
}
|
|
@@ -1,23 +1,45 @@
|
|
|
1
1
|
import type { BaseClientOptions } from "../BaseClient.mjs";
|
|
2
2
|
import * as core from "../core/index.mjs";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
3
|
+
declare const CLIENT_ID_PARAM: "clientId";
|
|
4
|
+
declare const CLIENT_SECRET_PARAM: "clientSecret";
|
|
5
|
+
declare const TOKEN_PARAM: "token";
|
|
7
6
|
export declare class OAuthAuthProvider implements core.AuthProvider {
|
|
8
|
-
private readonly
|
|
9
|
-
private readonly
|
|
10
|
-
private
|
|
11
|
-
private
|
|
12
|
-
private
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
getAuthRequest(
|
|
7
|
+
private readonly options;
|
|
8
|
+
private readonly authClient;
|
|
9
|
+
private accessToken;
|
|
10
|
+
private expiresAt;
|
|
11
|
+
private refreshPromise;
|
|
12
|
+
constructor(options: OAuthAuthProvider.Options & OAuthAuthProvider.ClientCredentials);
|
|
13
|
+
static canCreate(options?: Partial<OAuthAuthProvider.ClientCredentials & BaseClientOptions>): boolean;
|
|
14
|
+
private clientIdSupplier;
|
|
15
|
+
private clientSecretSupplier;
|
|
16
|
+
getAuthRequest({ endpointMetadata, }?: {
|
|
18
17
|
endpointMetadata?: core.EndpointMetadata;
|
|
19
18
|
}): Promise<core.AuthRequest>;
|
|
20
19
|
private getToken;
|
|
21
20
|
private refresh;
|
|
22
21
|
private getExpiresAt;
|
|
23
22
|
}
|
|
23
|
+
export declare class OAuthTokenOverrideAuthProvider implements core.AuthProvider {
|
|
24
|
+
private readonly options;
|
|
25
|
+
constructor(options: OAuthAuthProvider.TokenOverride);
|
|
26
|
+
static canCreate(options?: Partial<OAuthAuthProvider.TokenOverride & BaseClientOptions>): options is OAuthAuthProvider.TokenOverride;
|
|
27
|
+
getAuthRequest({ endpointMetadata, }?: {
|
|
28
|
+
endpointMetadata?: core.EndpointMetadata;
|
|
29
|
+
}): Promise<core.AuthRequest>;
|
|
30
|
+
}
|
|
31
|
+
export declare namespace OAuthAuthProvider {
|
|
32
|
+
const AUTH_SCHEME: "OAuthScheme";
|
|
33
|
+
const AUTH_CONFIG_ERROR_MESSAGE: string;
|
|
34
|
+
type ClientCredentials = {
|
|
35
|
+
[CLIENT_ID_PARAM]?: core.Supplier<string> | undefined;
|
|
36
|
+
[CLIENT_SECRET_PARAM]?: core.Supplier<string> | undefined;
|
|
37
|
+
};
|
|
38
|
+
type TokenOverride = {
|
|
39
|
+
[TOKEN_PARAM]: core.Supplier<string>;
|
|
40
|
+
};
|
|
41
|
+
type AuthOptions = ClientCredentials | TokenOverride;
|
|
42
|
+
type Options = BaseClientOptions & AuthOptions;
|
|
43
|
+
function createInstance(options: Options): core.AuthProvider;
|
|
44
|
+
}
|
|
45
|
+
export {};
|
|
@@ -11,22 +11,61 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
import { AuthClient } from "../api/resources/auth/client/Client.mjs";
|
|
12
12
|
import * as core from "../core/index.mjs";
|
|
13
13
|
import * as errors from "../errors/index.mjs";
|
|
14
|
+
const CLIENT_ID_PARAM = "clientId";
|
|
15
|
+
const CLIENT_SECRET_PARAM = "clientSecret";
|
|
16
|
+
const TOKEN_PARAM = "token";
|
|
17
|
+
const ENV_CLIENT_ID = "KARD_CLIENT_ID";
|
|
18
|
+
const ENV_CLIENT_SECRET = "KARD_CLIENT_SECRET";
|
|
19
|
+
const CLIENT_ID_REQUIRED_ERROR_MESSAGE = `${CLIENT_ID_PARAM} is required; either pass it as an argument or set the ${ENV_CLIENT_ID} environment variable`;
|
|
20
|
+
const CLIENT_SECRET_REQUIRED_ERROR_MESSAGE = `${CLIENT_SECRET_PARAM} is required; either pass it as an argument or set the ${ENV_CLIENT_SECRET} environment variable`;
|
|
21
|
+
const TOKEN_PARAM_REQUIRED_ERROR_MESSAGE = `${TOKEN_PARAM} is required. Please provide it in options.`;
|
|
22
|
+
const BUFFER_IN_MINUTES = 2;
|
|
14
23
|
export class OAuthAuthProvider {
|
|
15
24
|
constructor(options) {
|
|
16
|
-
this.
|
|
17
|
-
this.
|
|
18
|
-
this.
|
|
19
|
-
this._authClient = new AuthClient(options);
|
|
20
|
-
this._expiresAt = new Date();
|
|
25
|
+
this.options = options;
|
|
26
|
+
this.authClient = new AuthClient(options);
|
|
27
|
+
this.expiresAt = new Date();
|
|
21
28
|
}
|
|
22
29
|
static canCreate(options) {
|
|
23
30
|
var _a, _b;
|
|
24
|
-
return ((options
|
|
25
|
-
(options
|
|
31
|
+
return (((options === null || options === void 0 ? void 0 : options[CLIENT_ID_PARAM]) != null || ((_a = process.env) === null || _a === void 0 ? void 0 : _a[ENV_CLIENT_ID]) != null) &&
|
|
32
|
+
((options === null || options === void 0 ? void 0 : options[CLIENT_SECRET_PARAM]) != null || ((_b = process.env) === null || _b === void 0 ? void 0 : _b[ENV_CLIENT_SECRET]) != null));
|
|
26
33
|
}
|
|
27
|
-
|
|
28
|
-
return __awaiter(this,
|
|
29
|
-
|
|
34
|
+
clientIdSupplier() {
|
|
35
|
+
return __awaiter(this, arguments, void 0, function* ({ endpointMetadata, } = {}) {
|
|
36
|
+
var _a;
|
|
37
|
+
const supplier = this.options[CLIENT_ID_PARAM];
|
|
38
|
+
if (supplier != null) {
|
|
39
|
+
return core.EndpointSupplier.get(supplier, { endpointMetadata });
|
|
40
|
+
}
|
|
41
|
+
const envClientId = (_a = process.env) === null || _a === void 0 ? void 0 : _a[ENV_CLIENT_ID];
|
|
42
|
+
if (envClientId != null) {
|
|
43
|
+
return envClientId;
|
|
44
|
+
}
|
|
45
|
+
throw new errors.KardApiError({
|
|
46
|
+
message: CLIENT_ID_REQUIRED_ERROR_MESSAGE,
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
clientSecretSupplier() {
|
|
51
|
+
return __awaiter(this, arguments, void 0, function* ({ endpointMetadata, } = {}) {
|
|
52
|
+
var _a;
|
|
53
|
+
const supplier = this.options[CLIENT_SECRET_PARAM];
|
|
54
|
+
if (supplier != null) {
|
|
55
|
+
return core.EndpointSupplier.get(supplier, { endpointMetadata });
|
|
56
|
+
}
|
|
57
|
+
const envClientSecret = (_a = process.env) === null || _a === void 0 ? void 0 : _a[ENV_CLIENT_SECRET];
|
|
58
|
+
if (envClientSecret != null) {
|
|
59
|
+
return envClientSecret;
|
|
60
|
+
}
|
|
61
|
+
throw new errors.KardApiError({
|
|
62
|
+
message: CLIENT_SECRET_REQUIRED_ERROR_MESSAGE,
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
getAuthRequest() {
|
|
67
|
+
return __awaiter(this, arguments, void 0, function* ({ endpointMetadata, } = {}) {
|
|
68
|
+
const token = yield this.getToken({ endpointMetadata });
|
|
30
69
|
return {
|
|
31
70
|
headers: {
|
|
32
71
|
Authorization: `Bearer ${token}`,
|
|
@@ -34,48 +73,37 @@ export class OAuthAuthProvider {
|
|
|
34
73
|
};
|
|
35
74
|
});
|
|
36
75
|
}
|
|
37
|
-
getToken(
|
|
38
|
-
return __awaiter(this,
|
|
39
|
-
if (this.
|
|
40
|
-
return this.
|
|
76
|
+
getToken() {
|
|
77
|
+
return __awaiter(this, arguments, void 0, function* ({ endpointMetadata } = {}) {
|
|
78
|
+
if (this.accessToken && this.expiresAt > new Date()) {
|
|
79
|
+
return this.accessToken;
|
|
41
80
|
}
|
|
42
81
|
// If a refresh is already in progress, return the existing promise
|
|
43
|
-
if (this.
|
|
44
|
-
return this.
|
|
82
|
+
if (this.refreshPromise != null) {
|
|
83
|
+
return this.refreshPromise;
|
|
45
84
|
}
|
|
46
|
-
return this.refresh(
|
|
85
|
+
return this.refresh({ endpointMetadata });
|
|
47
86
|
});
|
|
48
87
|
}
|
|
49
|
-
refresh(
|
|
50
|
-
return __awaiter(this,
|
|
51
|
-
this.
|
|
52
|
-
var _a, _b, _c, _d;
|
|
88
|
+
refresh() {
|
|
89
|
+
return __awaiter(this, arguments, void 0, function* ({ endpointMetadata } = {}) {
|
|
90
|
+
this.refreshPromise = (() => __awaiter(this, void 0, void 0, function* () {
|
|
53
91
|
try {
|
|
54
|
-
const clientId =
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
message: "clientId is required; either pass it as an argument or set the KARD_CLIENT_ID environment variable",
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
const clientSecret = (_c = (yield core.Supplier.get(this._clientSecret))) !== null && _c !== void 0 ? _c : (_d = process.env) === null || _d === void 0 ? void 0 : _d.KARD_CLIENT_SECRET;
|
|
61
|
-
if (clientSecret == null) {
|
|
62
|
-
throw new errors.KardApiError({
|
|
63
|
-
message: "clientSecret is required; either pass it as an argument or set the KARD_CLIENT_SECRET environment variable",
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
const tokenResponse = yield this._authClient.getToken({
|
|
92
|
+
const clientId = yield this.clientIdSupplier({ endpointMetadata });
|
|
93
|
+
const clientSecret = yield this.clientSecretSupplier({ endpointMetadata });
|
|
94
|
+
const tokenResponse = yield this.authClient.getToken({
|
|
67
95
|
client_id: clientId,
|
|
68
96
|
client_secret: clientSecret,
|
|
69
97
|
});
|
|
70
|
-
this.
|
|
71
|
-
this.
|
|
72
|
-
return this.
|
|
98
|
+
this.accessToken = tokenResponse.access_token;
|
|
99
|
+
this.expiresAt = this.getExpiresAt(tokenResponse.expires_in, BUFFER_IN_MINUTES);
|
|
100
|
+
return this.accessToken;
|
|
73
101
|
}
|
|
74
102
|
finally {
|
|
75
|
-
this.
|
|
103
|
+
this.refreshPromise = undefined;
|
|
76
104
|
}
|
|
77
105
|
}))();
|
|
78
|
-
return this.
|
|
106
|
+
return this.refreshPromise;
|
|
79
107
|
});
|
|
80
108
|
}
|
|
81
109
|
getExpiresAt(expiresInSeconds, bufferInMinutes) {
|
|
@@ -83,3 +111,42 @@ export class OAuthAuthProvider {
|
|
|
83
111
|
return new Date(now.getTime() + expiresInSeconds * 1000 - bufferInMinutes * 60 * 1000);
|
|
84
112
|
}
|
|
85
113
|
}
|
|
114
|
+
export class OAuthTokenOverrideAuthProvider {
|
|
115
|
+
constructor(options) {
|
|
116
|
+
this.options = options;
|
|
117
|
+
}
|
|
118
|
+
static canCreate(options) {
|
|
119
|
+
return (options === null || options === void 0 ? void 0 : options[TOKEN_PARAM]) != null;
|
|
120
|
+
}
|
|
121
|
+
getAuthRequest() {
|
|
122
|
+
return __awaiter(this, arguments, void 0, function* ({ endpointMetadata, } = {}) {
|
|
123
|
+
const token = this.options[TOKEN_PARAM];
|
|
124
|
+
if (token == null) {
|
|
125
|
+
throw new errors.KardApiError({
|
|
126
|
+
message: TOKEN_PARAM_REQUIRED_ERROR_MESSAGE,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
return {
|
|
130
|
+
headers: {
|
|
131
|
+
Authorization: `Bearer ${yield core.EndpointSupplier.get(token, { endpointMetadata })}`,
|
|
132
|
+
},
|
|
133
|
+
};
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
(function (OAuthAuthProvider) {
|
|
138
|
+
OAuthAuthProvider.AUTH_SCHEME = "OAuthScheme";
|
|
139
|
+
OAuthAuthProvider.AUTH_CONFIG_ERROR_MESSAGE = `Insufficient options to create OAuthAuthProvider. Please provide either '${CLIENT_ID_PARAM}' or '${ENV_CLIENT_ID}' env var and '${CLIENT_SECRET_PARAM}' or '${ENV_CLIENT_SECRET}' env var, or ${TOKEN_PARAM}.`;
|
|
140
|
+
function createInstance(options) {
|
|
141
|
+
if (OAuthTokenOverrideAuthProvider.canCreate(options)) {
|
|
142
|
+
return new OAuthTokenOverrideAuthProvider(options);
|
|
143
|
+
}
|
|
144
|
+
else if (OAuthAuthProvider.canCreate(options)) {
|
|
145
|
+
return new OAuthAuthProvider(options);
|
|
146
|
+
}
|
|
147
|
+
throw new errors.KardApiError({
|
|
148
|
+
message: OAuthAuthProvider.AUTH_CONFIG_ERROR_MESSAGE,
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
OAuthAuthProvider.createInstance = createInstance;
|
|
152
|
+
})(OAuthAuthProvider || (OAuthAuthProvider = {}));
|
|
@@ -2,10 +2,16 @@ import { base64Decode, base64Encode } from "../base64.mjs";
|
|
|
2
2
|
const BASIC_AUTH_HEADER_PREFIX = /^Basic /i;
|
|
3
3
|
export const BasicAuth = {
|
|
4
4
|
toAuthorizationHeader: (basicAuth) => {
|
|
5
|
+
var _a, _b;
|
|
5
6
|
if (basicAuth == null) {
|
|
6
7
|
return undefined;
|
|
7
8
|
}
|
|
8
|
-
const
|
|
9
|
+
const username = (_a = basicAuth.username) !== null && _a !== void 0 ? _a : "";
|
|
10
|
+
const password = (_b = basicAuth.password) !== null && _b !== void 0 ? _b : "";
|
|
11
|
+
if (username === "" && password === "") {
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
14
|
+
const token = base64Encode(`${username}:${password}`);
|
|
9
15
|
return `Basic ${token}`;
|
|
10
16
|
},
|
|
11
17
|
fromAuthorizationHeader: (header) => {
|
|
@@ -14,6 +14,6 @@ export type BinaryResponse = {
|
|
|
14
14
|
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bytes)
|
|
15
15
|
* Some versions of the Fetch API may not support this method.
|
|
16
16
|
*/
|
|
17
|
-
bytes?():
|
|
17
|
+
bytes?(): Promise<Uint8Array>;
|
|
18
18
|
};
|
|
19
19
|
export declare function getBinaryResponse(response: Response): BinaryResponse;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { EndpointMetadata } from "./EndpointMetadata.mjs";
|
|
2
2
|
import type { Supplier } from "./Supplier.mjs";
|
|
3
3
|
type EndpointSupplierFn<T> = (arg: {
|
|
4
|
-
endpointMetadata
|
|
4
|
+
endpointMetadata?: EndpointMetadata;
|
|
5
5
|
}) => T | Promise<T>;
|
|
6
6
|
export type EndpointSupplier<T> = Supplier<T> | EndpointSupplierFn<T>;
|
|
7
7
|
export declare const EndpointSupplier: {
|
|
8
8
|
get: <T>(supplier: EndpointSupplier<T>, arg: {
|
|
9
|
-
endpointMetadata
|
|
9
|
+
endpointMetadata?: EndpointMetadata;
|
|
10
10
|
}) => Promise<T>;
|
|
11
11
|
};
|
|
12
12
|
export {};
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { type LogConfig, type Logger } from "../logging/logger.mjs";
|
|
2
2
|
import type { APIResponse } from "./APIResponse.mjs";
|
|
3
3
|
import type { EndpointMetadata } from "./EndpointMetadata.mjs";
|
|
4
|
-
import { EndpointSupplier } from "./EndpointSupplier.mjs";
|
|
5
4
|
export type FetchFunction = <R = unknown>(args: Fetcher.Args) => Promise<APIResponse<R, Fetcher.Error>>;
|
|
6
5
|
export declare namespace Fetcher {
|
|
7
6
|
interface Args {
|
|
8
7
|
url: string;
|
|
9
8
|
method: string;
|
|
10
9
|
contentType?: string;
|
|
11
|
-
headers?: Record<string,
|
|
10
|
+
headers?: Record<string, unknown>;
|
|
12
11
|
queryParameters?: Record<string, unknown>;
|
|
13
12
|
body?: unknown;
|
|
14
13
|
timeoutMs?: number;
|
|
@@ -39,10 +38,12 @@ export declare namespace Fetcher {
|
|
|
39
38
|
}
|
|
40
39
|
interface TimeoutError {
|
|
41
40
|
reason: "timeout";
|
|
41
|
+
cause?: unknown;
|
|
42
42
|
}
|
|
43
43
|
interface UnknownError {
|
|
44
44
|
reason: "unknown";
|
|
45
45
|
errorMessage: string;
|
|
46
|
+
cause?: unknown;
|
|
46
47
|
}
|
|
47
48
|
}
|
|
48
49
|
export declare function fetcherImpl<R = unknown>(args: Fetcher.Args): Promise<APIResponse<R, Fetcher.Error>>;
|
|
@@ -152,7 +152,13 @@ function getHeaders(args) {
|
|
|
152
152
|
return __awaiter(this, void 0, void 0, function* () {
|
|
153
153
|
var _a;
|
|
154
154
|
const newHeaders = new Headers();
|
|
155
|
-
newHeaders.set("Accept", args.responseType === "json"
|
|
155
|
+
newHeaders.set("Accept", args.responseType === "json"
|
|
156
|
+
? "application/json"
|
|
157
|
+
: args.responseType === "text"
|
|
158
|
+
? "text/plain"
|
|
159
|
+
: args.responseType === "sse"
|
|
160
|
+
? "text/event-stream"
|
|
161
|
+
: "*/*");
|
|
156
162
|
if (args.body !== undefined && args.contentType != null) {
|
|
157
163
|
newHeaders.set("Content-Type", args.contentType);
|
|
158
164
|
}
|
|
@@ -196,7 +202,7 @@ export function fetcherImpl(args) {
|
|
|
196
202
|
}
|
|
197
203
|
try {
|
|
198
204
|
const response = yield requestWithRetries(() => __awaiter(this, void 0, void 0, function* () {
|
|
199
|
-
return makeRequest(fetchFn, url, args.method, headers, requestBody, args.timeoutMs, args.abortSignal, args.withCredentials, args.duplex);
|
|
205
|
+
return makeRequest(fetchFn, url, args.method, headers, requestBody, args.timeoutMs, args.abortSignal, args.withCredentials, args.duplex, args.responseType === "streaming" || args.responseType === "sse");
|
|
200
206
|
}), args.maxRetries);
|
|
201
207
|
if (response.status >= 200 && response.status < 400) {
|
|
202
208
|
if (logger.isDebug()) {
|
|
@@ -251,6 +257,7 @@ export function fetcherImpl(args) {
|
|
|
251
257
|
error: {
|
|
252
258
|
reason: "unknown",
|
|
253
259
|
errorMessage: "The user aborted a request",
|
|
260
|
+
cause: error,
|
|
254
261
|
},
|
|
255
262
|
rawResponse: abortRawResponse,
|
|
256
263
|
};
|
|
@@ -268,6 +275,7 @@ export function fetcherImpl(args) {
|
|
|
268
275
|
ok: false,
|
|
269
276
|
error: {
|
|
270
277
|
reason: "timeout",
|
|
278
|
+
cause: error,
|
|
271
279
|
},
|
|
272
280
|
rawResponse: abortRawResponse,
|
|
273
281
|
};
|
|
@@ -286,6 +294,7 @@ export function fetcherImpl(args) {
|
|
|
286
294
|
error: {
|
|
287
295
|
reason: "unknown",
|
|
288
296
|
errorMessage: error.message,
|
|
297
|
+
cause: error,
|
|
289
298
|
},
|
|
290
299
|
rawResponse: unknownRawResponse,
|
|
291
300
|
};
|
|
@@ -303,6 +312,7 @@ export function fetcherImpl(args) {
|
|
|
303
312
|
error: {
|
|
304
313
|
reason: "unknown",
|
|
305
314
|
errorMessage: toJson(error),
|
|
315
|
+
cause: error,
|
|
306
316
|
},
|
|
307
317
|
rawResponse: unknownRawResponse,
|
|
308
318
|
};
|
|
@@ -6,6 +6,8 @@ export type { Fetcher, FetchFunction } from "./Fetcher.mjs";
|
|
|
6
6
|
export { fetcher } from "./Fetcher.mjs";
|
|
7
7
|
export { getHeader } from "./getHeader.mjs";
|
|
8
8
|
export { HttpResponsePromise } from "./HttpResponsePromise.mjs";
|
|
9
|
+
export type { PassthroughRequest } from "./makePassthroughRequest.mjs";
|
|
10
|
+
export { makePassthroughRequest } from "./makePassthroughRequest.mjs";
|
|
9
11
|
export type { RawResponse, WithRawResponse } from "./RawResponse.mjs";
|
|
10
12
|
export { abortRawResponse, toRawResponse, unknownRawResponse } from "./RawResponse.mjs";
|
|
11
13
|
export { Supplier } from "./Supplier.mjs";
|
|
@@ -2,5 +2,6 @@ export { EndpointSupplier } from "./EndpointSupplier.mjs";
|
|
|
2
2
|
export { fetcher } from "./Fetcher.mjs";
|
|
3
3
|
export { getHeader } from "./getHeader.mjs";
|
|
4
4
|
export { HttpResponsePromise } from "./HttpResponsePromise.mjs";
|
|
5
|
+
export { makePassthroughRequest } from "./makePassthroughRequest.mjs";
|
|
5
6
|
export { abortRawResponse, toRawResponse, unknownRawResponse } from "./RawResponse.mjs";
|
|
6
7
|
export { Supplier } from "./Supplier.mjs";
|