@spoketech/hub-client 0.1.8 → 0.1.9
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 +1 -1
- package/dist/index.d.ts +19 -2
- package/dist/index.js +133 -27
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -36,7 +36,7 @@ if (error !== null) {
|
|
|
36
36
|
console.log(data.items);
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
-
`error` is `null` on success. API failures include `kind: "api"`, `
|
|
39
|
+
`error` is `null` on success. API failures include `kind: "api"`, HTTP context such as `status`, `method`, and `url`, plus `code` and response `body` when the API returns a structured error; local signing, credential format, network, and unexpected failures are returned as structured client errors instead of thrown Effect fiber failures.
|
|
40
40
|
|
|
41
41
|
## Recommended Usage
|
|
42
42
|
|
package/dist/index.d.ts
CHANGED
|
@@ -6550,21 +6550,38 @@ type SpokeHubApiErrorBody = {
|
|
|
6550
6550
|
readonly [key: string]: unknown;
|
|
6551
6551
|
};
|
|
6552
6552
|
type SpokeHubErrorKind = "api" | "client" | "network" | "unknown";
|
|
6553
|
+
type SpokeHubHttpErrorContext = {
|
|
6554
|
+
readonly status?: number;
|
|
6555
|
+
readonly method?: string;
|
|
6556
|
+
readonly url?: string;
|
|
6557
|
+
readonly reason?: string;
|
|
6558
|
+
};
|
|
6553
6559
|
declare class SpokeHubClientError extends Error {
|
|
6554
6560
|
readonly kind: SpokeHubErrorKind;
|
|
6555
6561
|
readonly code?: string;
|
|
6556
6562
|
readonly body?: SpokeHubApiErrorBody;
|
|
6563
|
+
readonly status?: number;
|
|
6564
|
+
readonly method?: string;
|
|
6565
|
+
readonly url?: string;
|
|
6566
|
+
readonly reason?: string;
|
|
6557
6567
|
readonly cause: unknown;
|
|
6558
6568
|
constructor(input: {
|
|
6559
6569
|
readonly kind: SpokeHubErrorKind;
|
|
6560
6570
|
readonly message: string;
|
|
6561
6571
|
readonly code?: string;
|
|
6562
6572
|
readonly body?: SpokeHubApiErrorBody;
|
|
6573
|
+
readonly status?: number;
|
|
6574
|
+
readonly method?: string;
|
|
6575
|
+
readonly url?: string;
|
|
6576
|
+
readonly reason?: string;
|
|
6563
6577
|
readonly cause: unknown;
|
|
6564
6578
|
});
|
|
6579
|
+
toJSON(): {
|
|
6580
|
+
[k: string]: string | number | SpokeHubApiErrorBody | undefined;
|
|
6581
|
+
};
|
|
6565
6582
|
}
|
|
6566
6583
|
declare class SpokeHubApiError extends SpokeHubClientError {
|
|
6567
|
-
constructor(body: SpokeHubApiErrorBody, cause: unknown);
|
|
6584
|
+
constructor(body: SpokeHubApiErrorBody, cause: unknown, context?: SpokeHubHttpErrorContext);
|
|
6568
6585
|
}
|
|
6569
6586
|
declare function resolveHubApiBaseUrl(baseUrl: string | URL, apiBasePath?: string): string;
|
|
6570
6587
|
declare const makeHubApiClient: (options: HubApiClientOptions) => Effect.Effect<{
|
|
@@ -37368,4 +37385,4 @@ declare const makePromiseSpokeClient: (options: HubApiCredentialOptions) => Prom
|
|
|
37368
37385
|
readonly hubClient: PromiseHubApiClient;
|
|
37369
37386
|
}>;
|
|
37370
37387
|
|
|
37371
|
-
export { AddressSchema, type AdminSession, AdminSessionSchema, type BadRequestError, BadRequestErrorSchema, type BootstrapOrganizationMemberSourceAgentInput, type BootstrapOrganizationMemberSourceAgentResponse, BootstrapOrganizationMemberSourceAgentResponseSchema, BootstrapOrganizationMemberSourceAgentSchema, type BulkGetOrganizationMembersInput, BulkGetOrganizationMembersSchema, type BulkOrganizationMembersBasicResponse, BulkOrganizationMembersBasicResponseSchema, type BulkOrganizationMembersMedResponse, BulkOrganizationMembersMedResponseSchema, type BulkOrganizationMembersResponse, BulkOrganizationMembersResponseSchema, type BulkOrganizationMembersResponseUnion, BulkOrganizationMembersResponseUnionSchema, type CompleteOnsiteVoucherCommandInput, CompleteOnsiteVoucherCommandSchema, type ConflictError, ConflictErrorSchema, type CreateGuestInput, CreateGuestSchema, type CreateMemberInput, CreateMemberSchema, type CreateOrganizationInput, type CreateOrganizationMemberSourceCsvUploadInput, type CreateOrganizationMemberSourceCsvUploadResponse, CreateOrganizationMemberSourceCsvUploadResponseSchema, CreateOrganizationMemberSourceCsvUploadSchema, type CreateOrganizationPointTypeInput, CreateOrganizationPointTypeSchema, type CreateOrganizationProductOptionInput, CreateOrganizationProductOptionSchema, type CreateOrganizationProductWebhookInput, CreateOrganizationProductWebhookSchema, CreateOrganizationSchema, type CreateServiceClientInput, CreateServiceClientSchema, type CsvUploadReadiness, CsvUploadReadinessSchema, DateOnlySchema, type DeletePayload, DeletePayloadSchema, type DeleteServiceClientInput, DeleteServiceClientSchema, type ForbiddenError, ForbiddenErrorSchema, type Guest, type GuestContactMatch, GuestContactMatchSchema, GuestSchema, HubApi, type HubApiClient, type HubApiClientOptions, type HubApiCredentialOptions, type ImportedMemberRecord, ImportedMemberRecordSchema, IssuedPrivateKeySchema, MarketingPreferencesSchema, type Member, type MemberBasic, type MemberBasicResponse, MemberBasicResponseSchema, MemberBasicSchema, type MemberContactMatch, MemberContactMatchSchema, type MemberFullResponse, MemberFullResponseSchema, type MemberMed, type MemberMedResponse, MemberMedResponseSchema, MemberMedSchema, type MemberPointBalance, MemberPointBalanceSchema, type MemberPointBalancesResponse, MemberPointBalancesResponseSchema, type MemberResponse, type MemberResponseMode, MemberResponseModeSchema, MemberResponseSchema, MemberSchema, MemberSourceSecretNameSchema, type MemberStatusCredits, MemberStatusCreditsSchema, type NotFoundError, NotFoundErrorSchema, type OnsiteAgentCommand, OnsiteAgentCommandSchema, type OnsiteAgentCompleteMemberCreateInput, OnsiteAgentCompleteMemberCreateSchema, type OnsiteAgentCompleteMemberLookupInput, OnsiteAgentCompleteMemberLookupSchema, type OnsiteAgentCompleteMemberRenewalInput, OnsiteAgentCompleteMemberRenewalSchema, type OnsiteAgentCompleteMemberUpdateInput, OnsiteAgentCompleteMemberUpdateSchema, OnsiteAgentCompleteRunErrorSchema, type OnsiteAgentCompleteRunInput, OnsiteAgentCompleteRunSchema, type OnsiteAgentCsvUploadTarget, OnsiteAgentCsvUploadTargetSchema, type OnsiteAgentHeartbeatInput, type OnsiteAgentHeartbeatResponse, OnsiteAgentHeartbeatResponseSchema, OnsiteAgentHeartbeatSchema, type OnsiteAgentIngestLiveFbiBatchInput, OnsiteAgentIngestLiveFbiBatchSchema, type OnsiteAgentMemberCreateCommand, OnsiteAgentMemberCreateCommandSchema, type OnsiteAgentMemberLookupCommand, OnsiteAgentMemberLookupCommandSchema, type OnsiteAgentMemberRenewalCommand, OnsiteAgentMemberRenewalCommandSchema, type OnsiteAgentMemberUpdateCommand, OnsiteAgentMemberUpdateCommandSchema, type OnsiteResourceCallRequest, OnsiteResourceCallRequestSchema, type OnsiteResourceCallResponse, OnsiteResourceCallResponseSchema, type OnsiteResourceClient, type OnsiteResourceMemberCallResponse, OnsiteResourceMemberCallResponseSchema, type OnsiteResourceVoucherCallResponse, OnsiteResourceVoucherCallResponseSchema, type OnsiteVoucherCommand, OnsiteVoucherCommandSchema, type Organization, type OrganizationMemberGender, OrganizationMemberGenderSchema, type OrganizationMemberMembershipType, OrganizationMemberMembershipTypeSchema, type OrganizationMemberRatingGrade, OrganizationMemberRatingGradeSchema, type OrganizationMemberSource, type OrganizationMemberSourceAgent, OrganizationMemberSourceAgentSchema, type OrganizationMemberSourceCommand, OrganizationMemberSourceCommandSchema, type OrganizationMemberSourceCsvImport, OrganizationMemberSourceCsvImportSchema, type OrganizationMemberSourceCsvMapping, OrganizationMemberSourceCsvMappingSchema, OrganizationMemberSourceSchema, OrganizationMemberSourceSecretInputSchema, type OrganizationMemberSourceWebhook, OrganizationMemberSourceWebhookSchema, type OrganizationMemberSourceWebhookUpsertResponse, OrganizationMemberSourceWebhookUpsertResponseSchema, type OrganizationMemberSyncRun, type OrganizationMemberSyncRunError, OrganizationMemberSyncRunErrorSchema, OrganizationMemberSyncRunSchema, OrganizationMemberSyncRunSummarySchema, type OrganizationMemberTitle, OrganizationMemberTitleSchema, type OrganizationMembersListResponse, type OrganizationMembersSearchField, OrganizationMembersSearchFieldSchema, type OrganizationMembersSortField, OrganizationMembersSortFieldSchema, type OrganizationMembersStatusFilter, OrganizationMembersStatusFilterSchema, type OrganizationPeopleContactLookupResponse, OrganizationPeopleContactLookupResponseSchema, type OrganizationPointType, OrganizationPointTypeSchema, type OrganizationPointTypesResponse, OrganizationPointTypesResponseSchema, type OrganizationProductOption, OrganizationProductOptionSchema, type OrganizationProductWebhook, OrganizationProductWebhookSchema, type OrganizationProductWebhookUpsertResponse, OrganizationProductWebhookUpsertResponseSchema, OrganizationSchema, type OrganizationVoucherCommand, OrganizationVoucherCommandSchema, type OrganizationVoucherProvider, OrganizationVoucherProviderSchema, OrganizationVoucherProviderSecretInputSchema, OrganizationVoucherProviderSecretNameSchema, type PaginatedGuests, PaginatedGuestsSchema, type PaginatedOrganizationMemberGenders, PaginatedOrganizationMemberGendersSchema, type PaginatedOrganizationMemberMembershipTypes, PaginatedOrganizationMemberMembershipTypesSchema, type PaginatedOrganizationMemberRatingGrades, PaginatedOrganizationMemberRatingGradesSchema, type PaginatedOrganizationMemberSourceCommands, PaginatedOrganizationMemberSourceCommandsSchema, type PaginatedOrganizationMemberSyncRuns, PaginatedOrganizationMemberSyncRunsSchema, type PaginatedOrganizationMemberTitles, PaginatedOrganizationMemberTitlesSchema, type PaginatedOrganizationMembers, type PaginatedOrganizationMembersBasic, PaginatedOrganizationMembersBasicSchema, type PaginatedOrganizationMembersMed, PaginatedOrganizationMembersMedSchema, PaginatedOrganizationMembersResponseSchema, PaginatedOrganizationMembersSchema, type PaginatedOrganizationProductOptions, PaginatedOrganizationProductOptionsSchema, type PaginatedOrganizationProductWebhooks, PaginatedOrganizationProductWebhooksSchema, type PaginatedOrganizations, PaginatedOrganizationsSchema, type PaginatedServiceClients, PaginatedServiceClientsSchema, PresignedPostSchema, type PromiseClient, type PromiseHubApiClient, type PromiseSpokeClient, type RequestSourceManagedMemberCreateInput, RequestSourceManagedMemberCreateSchema, type RequestSourceManagedMemberRenewalInput, RequestSourceManagedMemberRenewalSchema, type RequestSourceManagedMemberUpdateInput, RequestSourceManagedMemberUpdateSchema, type RequestVoucherIssueInput, RequestVoucherIssueSchema, type ServiceClient, ServiceClientSchema, type SortDirection, SortDirectionSchema, type SourceManagedMemberLookupBy, SourceManagedMemberLookupBySchema, type SourceManagedMemberLookupCommandPayload, SourceManagedMemberLookupCommandPayloadSchema, type SourceManagedMemberRenewalCommandPayload, SourceManagedMemberRenewalCommandPayloadSchema, SourceManagedMemberUpdateCommandPayloadSchema, SpokeHubApiError, type SpokeHubApiErrorBody, SpokeHubClientError, type SpokeHubErrorKind, type SpokeHubResult, TimestampSchema, type TriggerOrganizationMemberSyncInput, TriggerOrganizationMemberSyncSchema, type UnauthorizedError, UnauthorizedErrorSchema, type UpdateGuestInput, UpdateGuestSchema, type UpdateMemberInput, UpdateMemberSchema, type UpdateMemberStatusCreditsInput, UpdateMemberStatusCreditsSchema, type UpdateOrganizationInput, type UpdateOrganizationPointTypeInput, UpdateOrganizationPointTypeSchema, type UpdateOrganizationProductWebhookInput, UpdateOrganizationProductWebhookSchema, UpdateOrganizationSchema, type UpdateServiceClientInput, UpdateServiceClientSchema, type UpsertMemberPointBalanceInput, UpsertMemberPointBalanceSchema, type UpsertOrganizationMemberSourceCsvMappingInput, UpsertOrganizationMemberSourceCsvMappingSchema, type UpsertOrganizationMemberSourceInput, UpsertOrganizationMemberSourceSchema, type UpsertOrganizationMemberSourceWebhookInput, UpsertOrganizationMemberSourceWebhookSchema, type UpsertOrganizationProductWebhookInput, UpsertOrganizationProductWebhookSchema, type UpsertOrganizationVoucherProviderInput, UpsertOrganizationVoucherProviderSchema, adminRoles, guestStatuses, makeBadRequest, makeConflict, makeForbidden, makeHubApiClient, makeNotFound, makeOnsiteResourceClient, makePromiseHubApiClient, makePromiseOnsiteResourceClient, makePromiseServiceHubApiClient, makePromiseSpokeClient, makeServiceHubApiClient, makeSpokeClient, makeUnauthorized, memberComputedStatuses, memberCreatedOrigins, memberPreferredContactMethods, memberRecordModes, memberStatuses, organizationMemberSourceAgentStatuses, organizationMemberSourceBatchTransports, organizationMemberSourceCommandKinds, organizationMemberSourceCommandStatuses, organizationMemberSourceCsvImportStatuses, organizationMemberSourceLiveTransports, organizationMemberSourceManualTransports, organizationMemberSourceStatuses, organizationMemberSourceVendors, organizationMemberSourceWebhookDeliveryStatuses, organizationMemberSourceWebhookStatuses, organizationMemberSyncModes, organizationMemberSyncRunStatuses, organizationMemberSyncTransports, organizationMemberSyncTriggerKinds, organizationPointTypeStatuses, organizationProductWebhookDeliveryStatuses, organizationProductWebhookStatuses, organizationStatuses, organizationVoucherCommandKinds, organizationVoucherCommandStatuses, organizationVoucherProviderProviders, organizationVoucherProviderStatuses, organizationVoucherProviderTransports, resolveHubApiBaseUrl };
|
|
37388
|
+
export { AddressSchema, type AdminSession, AdminSessionSchema, type BadRequestError, BadRequestErrorSchema, type BootstrapOrganizationMemberSourceAgentInput, type BootstrapOrganizationMemberSourceAgentResponse, BootstrapOrganizationMemberSourceAgentResponseSchema, BootstrapOrganizationMemberSourceAgentSchema, type BulkGetOrganizationMembersInput, BulkGetOrganizationMembersSchema, type BulkOrganizationMembersBasicResponse, BulkOrganizationMembersBasicResponseSchema, type BulkOrganizationMembersMedResponse, BulkOrganizationMembersMedResponseSchema, type BulkOrganizationMembersResponse, BulkOrganizationMembersResponseSchema, type BulkOrganizationMembersResponseUnion, BulkOrganizationMembersResponseUnionSchema, type CompleteOnsiteVoucherCommandInput, CompleteOnsiteVoucherCommandSchema, type ConflictError, ConflictErrorSchema, type CreateGuestInput, CreateGuestSchema, type CreateMemberInput, CreateMemberSchema, type CreateOrganizationInput, type CreateOrganizationMemberSourceCsvUploadInput, type CreateOrganizationMemberSourceCsvUploadResponse, CreateOrganizationMemberSourceCsvUploadResponseSchema, CreateOrganizationMemberSourceCsvUploadSchema, type CreateOrganizationPointTypeInput, CreateOrganizationPointTypeSchema, type CreateOrganizationProductOptionInput, CreateOrganizationProductOptionSchema, type CreateOrganizationProductWebhookInput, CreateOrganizationProductWebhookSchema, CreateOrganizationSchema, type CreateServiceClientInput, CreateServiceClientSchema, type CsvUploadReadiness, CsvUploadReadinessSchema, DateOnlySchema, type DeletePayload, DeletePayloadSchema, type DeleteServiceClientInput, DeleteServiceClientSchema, type ForbiddenError, ForbiddenErrorSchema, type Guest, type GuestContactMatch, GuestContactMatchSchema, GuestSchema, HubApi, type HubApiClient, type HubApiClientOptions, type HubApiCredentialOptions, type ImportedMemberRecord, ImportedMemberRecordSchema, IssuedPrivateKeySchema, MarketingPreferencesSchema, type Member, type MemberBasic, type MemberBasicResponse, MemberBasicResponseSchema, MemberBasicSchema, type MemberContactMatch, MemberContactMatchSchema, type MemberFullResponse, MemberFullResponseSchema, type MemberMed, type MemberMedResponse, MemberMedResponseSchema, MemberMedSchema, type MemberPointBalance, MemberPointBalanceSchema, type MemberPointBalancesResponse, MemberPointBalancesResponseSchema, type MemberResponse, type MemberResponseMode, MemberResponseModeSchema, MemberResponseSchema, MemberSchema, MemberSourceSecretNameSchema, type MemberStatusCredits, MemberStatusCreditsSchema, type NotFoundError, NotFoundErrorSchema, type OnsiteAgentCommand, OnsiteAgentCommandSchema, type OnsiteAgentCompleteMemberCreateInput, OnsiteAgentCompleteMemberCreateSchema, type OnsiteAgentCompleteMemberLookupInput, OnsiteAgentCompleteMemberLookupSchema, type OnsiteAgentCompleteMemberRenewalInput, OnsiteAgentCompleteMemberRenewalSchema, type OnsiteAgentCompleteMemberUpdateInput, OnsiteAgentCompleteMemberUpdateSchema, OnsiteAgentCompleteRunErrorSchema, type OnsiteAgentCompleteRunInput, OnsiteAgentCompleteRunSchema, type OnsiteAgentCsvUploadTarget, OnsiteAgentCsvUploadTargetSchema, type OnsiteAgentHeartbeatInput, type OnsiteAgentHeartbeatResponse, OnsiteAgentHeartbeatResponseSchema, OnsiteAgentHeartbeatSchema, type OnsiteAgentIngestLiveFbiBatchInput, OnsiteAgentIngestLiveFbiBatchSchema, type OnsiteAgentMemberCreateCommand, OnsiteAgentMemberCreateCommandSchema, type OnsiteAgentMemberLookupCommand, OnsiteAgentMemberLookupCommandSchema, type OnsiteAgentMemberRenewalCommand, OnsiteAgentMemberRenewalCommandSchema, type OnsiteAgentMemberUpdateCommand, OnsiteAgentMemberUpdateCommandSchema, type OnsiteResourceCallRequest, OnsiteResourceCallRequestSchema, type OnsiteResourceCallResponse, OnsiteResourceCallResponseSchema, type OnsiteResourceClient, type OnsiteResourceMemberCallResponse, OnsiteResourceMemberCallResponseSchema, type OnsiteResourceVoucherCallResponse, OnsiteResourceVoucherCallResponseSchema, type OnsiteVoucherCommand, OnsiteVoucherCommandSchema, type Organization, type OrganizationMemberGender, OrganizationMemberGenderSchema, type OrganizationMemberMembershipType, OrganizationMemberMembershipTypeSchema, type OrganizationMemberRatingGrade, OrganizationMemberRatingGradeSchema, type OrganizationMemberSource, type OrganizationMemberSourceAgent, OrganizationMemberSourceAgentSchema, type OrganizationMemberSourceCommand, OrganizationMemberSourceCommandSchema, type OrganizationMemberSourceCsvImport, OrganizationMemberSourceCsvImportSchema, type OrganizationMemberSourceCsvMapping, OrganizationMemberSourceCsvMappingSchema, OrganizationMemberSourceSchema, OrganizationMemberSourceSecretInputSchema, type OrganizationMemberSourceWebhook, OrganizationMemberSourceWebhookSchema, type OrganizationMemberSourceWebhookUpsertResponse, OrganizationMemberSourceWebhookUpsertResponseSchema, type OrganizationMemberSyncRun, type OrganizationMemberSyncRunError, OrganizationMemberSyncRunErrorSchema, OrganizationMemberSyncRunSchema, OrganizationMemberSyncRunSummarySchema, type OrganizationMemberTitle, OrganizationMemberTitleSchema, type OrganizationMembersListResponse, type OrganizationMembersSearchField, OrganizationMembersSearchFieldSchema, type OrganizationMembersSortField, OrganizationMembersSortFieldSchema, type OrganizationMembersStatusFilter, OrganizationMembersStatusFilterSchema, type OrganizationPeopleContactLookupResponse, OrganizationPeopleContactLookupResponseSchema, type OrganizationPointType, OrganizationPointTypeSchema, type OrganizationPointTypesResponse, OrganizationPointTypesResponseSchema, type OrganizationProductOption, OrganizationProductOptionSchema, type OrganizationProductWebhook, OrganizationProductWebhookSchema, type OrganizationProductWebhookUpsertResponse, OrganizationProductWebhookUpsertResponseSchema, OrganizationSchema, type OrganizationVoucherCommand, OrganizationVoucherCommandSchema, type OrganizationVoucherProvider, OrganizationVoucherProviderSchema, OrganizationVoucherProviderSecretInputSchema, OrganizationVoucherProviderSecretNameSchema, type PaginatedGuests, PaginatedGuestsSchema, type PaginatedOrganizationMemberGenders, PaginatedOrganizationMemberGendersSchema, type PaginatedOrganizationMemberMembershipTypes, PaginatedOrganizationMemberMembershipTypesSchema, type PaginatedOrganizationMemberRatingGrades, PaginatedOrganizationMemberRatingGradesSchema, type PaginatedOrganizationMemberSourceCommands, PaginatedOrganizationMemberSourceCommandsSchema, type PaginatedOrganizationMemberSyncRuns, PaginatedOrganizationMemberSyncRunsSchema, type PaginatedOrganizationMemberTitles, PaginatedOrganizationMemberTitlesSchema, type PaginatedOrganizationMembers, type PaginatedOrganizationMembersBasic, PaginatedOrganizationMembersBasicSchema, type PaginatedOrganizationMembersMed, PaginatedOrganizationMembersMedSchema, PaginatedOrganizationMembersResponseSchema, PaginatedOrganizationMembersSchema, type PaginatedOrganizationProductOptions, PaginatedOrganizationProductOptionsSchema, type PaginatedOrganizationProductWebhooks, PaginatedOrganizationProductWebhooksSchema, type PaginatedOrganizations, PaginatedOrganizationsSchema, type PaginatedServiceClients, PaginatedServiceClientsSchema, PresignedPostSchema, type PromiseClient, type PromiseHubApiClient, type PromiseSpokeClient, type RequestSourceManagedMemberCreateInput, RequestSourceManagedMemberCreateSchema, type RequestSourceManagedMemberRenewalInput, RequestSourceManagedMemberRenewalSchema, type RequestSourceManagedMemberUpdateInput, RequestSourceManagedMemberUpdateSchema, type RequestVoucherIssueInput, RequestVoucherIssueSchema, type ServiceClient, ServiceClientSchema, type SortDirection, SortDirectionSchema, type SourceManagedMemberLookupBy, SourceManagedMemberLookupBySchema, type SourceManagedMemberLookupCommandPayload, SourceManagedMemberLookupCommandPayloadSchema, type SourceManagedMemberRenewalCommandPayload, SourceManagedMemberRenewalCommandPayloadSchema, SourceManagedMemberUpdateCommandPayloadSchema, SpokeHubApiError, type SpokeHubApiErrorBody, SpokeHubClientError, type SpokeHubErrorKind, type SpokeHubHttpErrorContext, type SpokeHubResult, TimestampSchema, type TriggerOrganizationMemberSyncInput, TriggerOrganizationMemberSyncSchema, type UnauthorizedError, UnauthorizedErrorSchema, type UpdateGuestInput, UpdateGuestSchema, type UpdateMemberInput, UpdateMemberSchema, type UpdateMemberStatusCreditsInput, UpdateMemberStatusCreditsSchema, type UpdateOrganizationInput, type UpdateOrganizationPointTypeInput, UpdateOrganizationPointTypeSchema, type UpdateOrganizationProductWebhookInput, UpdateOrganizationProductWebhookSchema, UpdateOrganizationSchema, type UpdateServiceClientInput, UpdateServiceClientSchema, type UpsertMemberPointBalanceInput, UpsertMemberPointBalanceSchema, type UpsertOrganizationMemberSourceCsvMappingInput, UpsertOrganizationMemberSourceCsvMappingSchema, type UpsertOrganizationMemberSourceInput, UpsertOrganizationMemberSourceSchema, type UpsertOrganizationMemberSourceWebhookInput, UpsertOrganizationMemberSourceWebhookSchema, type UpsertOrganizationProductWebhookInput, UpsertOrganizationProductWebhookSchema, type UpsertOrganizationVoucherProviderInput, UpsertOrganizationVoucherProviderSchema, adminRoles, guestStatuses, makeBadRequest, makeConflict, makeForbidden, makeHubApiClient, makeNotFound, makeOnsiteResourceClient, makePromiseHubApiClient, makePromiseOnsiteResourceClient, makePromiseServiceHubApiClient, makePromiseSpokeClient, makeServiceHubApiClient, makeSpokeClient, makeUnauthorized, memberComputedStatuses, memberCreatedOrigins, memberPreferredContactMethods, memberRecordModes, memberStatuses, organizationMemberSourceAgentStatuses, organizationMemberSourceBatchTransports, organizationMemberSourceCommandKinds, organizationMemberSourceCommandStatuses, organizationMemberSourceCsvImportStatuses, organizationMemberSourceLiveTransports, organizationMemberSourceManualTransports, organizationMemberSourceStatuses, organizationMemberSourceVendors, organizationMemberSourceWebhookDeliveryStatuses, organizationMemberSourceWebhookStatuses, organizationMemberSyncModes, organizationMemberSyncRunStatuses, organizationMemberSyncTransports, organizationMemberSyncTriggerKinds, organizationPointTypeStatuses, organizationProductWebhookDeliveryStatuses, organizationProductWebhookStatuses, organizationStatuses, organizationVoucherCommandKinds, organizationVoucherCommandStatuses, organizationVoucherProviderProviders, organizationVoucherProviderStatuses, organizationVoucherProviderTransports, resolveHubApiBaseUrl };
|
package/dist/index.js
CHANGED
|
@@ -3715,6 +3715,10 @@ var SpokeHubClientError = class extends Error {
|
|
|
3715
3715
|
kind;
|
|
3716
3716
|
code;
|
|
3717
3717
|
body;
|
|
3718
|
+
status;
|
|
3719
|
+
method;
|
|
3720
|
+
url;
|
|
3721
|
+
reason;
|
|
3718
3722
|
cause;
|
|
3719
3723
|
constructor(input) {
|
|
3720
3724
|
super(input.message);
|
|
@@ -3722,16 +3726,47 @@ var SpokeHubClientError = class extends Error {
|
|
|
3722
3726
|
this.kind = input.kind;
|
|
3723
3727
|
this.code = input.code;
|
|
3724
3728
|
this.body = input.body;
|
|
3729
|
+
this.status = input.status;
|
|
3730
|
+
this.method = input.method;
|
|
3731
|
+
this.url = input.url;
|
|
3732
|
+
this.reason = input.reason;
|
|
3725
3733
|
this.cause = input.cause;
|
|
3734
|
+
Object.defineProperty(this, "cause", {
|
|
3735
|
+
value: input.cause,
|
|
3736
|
+
enumerable: false,
|
|
3737
|
+
configurable: true
|
|
3738
|
+
});
|
|
3739
|
+
}
|
|
3740
|
+
toJSON() {
|
|
3741
|
+
return Object.fromEntries(
|
|
3742
|
+
Object.entries({
|
|
3743
|
+
name: this.name,
|
|
3744
|
+
kind: this.kind,
|
|
3745
|
+
code: this.code,
|
|
3746
|
+
message: this.message,
|
|
3747
|
+
status: this.status,
|
|
3748
|
+
method: this.method,
|
|
3749
|
+
url: this.url,
|
|
3750
|
+
reason: this.reason,
|
|
3751
|
+
body: this.body
|
|
3752
|
+
}).filter(([, value]) => value !== void 0)
|
|
3753
|
+
);
|
|
3754
|
+
}
|
|
3755
|
+
[/* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom")]() {
|
|
3756
|
+
return this.toJSON();
|
|
3726
3757
|
}
|
|
3727
3758
|
};
|
|
3728
3759
|
var SpokeHubApiError = class extends SpokeHubClientError {
|
|
3729
|
-
constructor(body, cause) {
|
|
3760
|
+
constructor(body, cause, context = {}) {
|
|
3730
3761
|
super({
|
|
3731
3762
|
kind: "api",
|
|
3732
3763
|
message: body.message ?? body.code ?? "Spoke Hub API request failed",
|
|
3733
3764
|
code: body.code,
|
|
3734
3765
|
body,
|
|
3766
|
+
status: context.status,
|
|
3767
|
+
method: context.method,
|
|
3768
|
+
url: context.url,
|
|
3769
|
+
reason: context.reason,
|
|
3735
3770
|
cause
|
|
3736
3771
|
});
|
|
3737
3772
|
this.name = "SpokeHubApiError";
|
|
@@ -3829,6 +3864,81 @@ function configureSignedHttpClient(client, options) {
|
|
|
3829
3864
|
})
|
|
3830
3865
|
);
|
|
3831
3866
|
}
|
|
3867
|
+
var fiberFailureCauseSymbol = /* @__PURE__ */ Symbol.for("effect/Runtime/FiberFailure/Cause");
|
|
3868
|
+
function isRecord(value) {
|
|
3869
|
+
return !!value && typeof value === "object";
|
|
3870
|
+
}
|
|
3871
|
+
function stringFromUnknown(value) {
|
|
3872
|
+
if (typeof value === "string" && value.length > 0) {
|
|
3873
|
+
return value;
|
|
3874
|
+
}
|
|
3875
|
+
if (value instanceof URL) {
|
|
3876
|
+
return value.toString();
|
|
3877
|
+
}
|
|
3878
|
+
return void 0;
|
|
3879
|
+
}
|
|
3880
|
+
function numberFromUnknown(value) {
|
|
3881
|
+
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
3882
|
+
}
|
|
3883
|
+
function failureErrorFromUnknown(value) {
|
|
3884
|
+
if (!isRecord(value)) {
|
|
3885
|
+
return void 0;
|
|
3886
|
+
}
|
|
3887
|
+
const fiberFailureCause = value[fiberFailureCauseSymbol];
|
|
3888
|
+
if (isRecord(fiberFailureCause) && "error" in fiberFailureCause) {
|
|
3889
|
+
return fiberFailureCause.error;
|
|
3890
|
+
}
|
|
3891
|
+
return void 0;
|
|
3892
|
+
}
|
|
3893
|
+
function errorCandidatesFromUnknown(value) {
|
|
3894
|
+
const candidates = [value];
|
|
3895
|
+
const failureError = failureErrorFromUnknown(value);
|
|
3896
|
+
if (failureError) {
|
|
3897
|
+
candidates.push(failureError);
|
|
3898
|
+
}
|
|
3899
|
+
for (const candidate of [...candidates]) {
|
|
3900
|
+
if (candidate instanceof Error && candidate.cause) {
|
|
3901
|
+
candidates.push(candidate.cause);
|
|
3902
|
+
} else if (isRecord(candidate) && candidate.cause) {
|
|
3903
|
+
candidates.push(candidate.cause);
|
|
3904
|
+
}
|
|
3905
|
+
}
|
|
3906
|
+
return candidates;
|
|
3907
|
+
}
|
|
3908
|
+
function httpContextFromMessage(message) {
|
|
3909
|
+
const match = message.match(/\((\d{3})\s+([A-Z]+)\s+([^)]+)\)/);
|
|
3910
|
+
if (!match) {
|
|
3911
|
+
return {};
|
|
3912
|
+
}
|
|
3913
|
+
return {
|
|
3914
|
+
status: Number(match[1]),
|
|
3915
|
+
method: match[2],
|
|
3916
|
+
url: match[3]
|
|
3917
|
+
};
|
|
3918
|
+
}
|
|
3919
|
+
function httpContextFromUnknown(value) {
|
|
3920
|
+
const context = {};
|
|
3921
|
+
for (const candidate of errorCandidatesFromUnknown(value)) {
|
|
3922
|
+
if (candidate instanceof Error) {
|
|
3923
|
+
Object.assign(context, httpContextFromMessage(candidate.message));
|
|
3924
|
+
}
|
|
3925
|
+
if (!isRecord(candidate)) {
|
|
3926
|
+
continue;
|
|
3927
|
+
}
|
|
3928
|
+
const request = candidate.request;
|
|
3929
|
+
const response = candidate.response;
|
|
3930
|
+
const requestRecord = isRecord(request) ? request : void 0;
|
|
3931
|
+
const responseRecord = isRecord(response) ? response : void 0;
|
|
3932
|
+
context.status ??= numberFromUnknown(responseRecord?.status);
|
|
3933
|
+
context.method ??= stringFromUnknown(requestRecord?.method);
|
|
3934
|
+
context.url ??= stringFromUnknown(requestRecord?.url) ?? stringFromUnknown(responseRecord?.url);
|
|
3935
|
+
context.reason ??= stringFromUnknown(candidate.reason);
|
|
3936
|
+
if (context.status !== void 0 && context.method !== void 0 && context.url !== void 0 && context.reason !== void 0) {
|
|
3937
|
+
break;
|
|
3938
|
+
}
|
|
3939
|
+
}
|
|
3940
|
+
return context;
|
|
3941
|
+
}
|
|
3832
3942
|
function hasApiErrorBody(value) {
|
|
3833
3943
|
if (value instanceof Error) {
|
|
3834
3944
|
return false;
|
|
@@ -3837,40 +3947,29 @@ function hasApiErrorBody(value) {
|
|
|
3837
3947
|
return !!value && typeof value === "object" && (typeof body.message === "string" || typeof body.code === "string");
|
|
3838
3948
|
}
|
|
3839
3949
|
function apiErrorBodyFromUnknown(value) {
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
if (value instanceof Error) {
|
|
3844
|
-
const cause = value.cause;
|
|
3845
|
-
if (hasApiErrorBody(cause)) {
|
|
3846
|
-
return cause;
|
|
3847
|
-
}
|
|
3848
|
-
}
|
|
3849
|
-
if (value && typeof value === "object") {
|
|
3850
|
-
const cause = value.cause;
|
|
3851
|
-
if (hasApiErrorBody(cause)) {
|
|
3852
|
-
return cause;
|
|
3853
|
-
}
|
|
3854
|
-
const fiberFailureCause = value[/* @__PURE__ */ Symbol.for("effect/Runtime/FiberFailure/Cause")];
|
|
3855
|
-
if (fiberFailureCause && typeof fiberFailureCause === "object") {
|
|
3856
|
-
const error = fiberFailureCause.error;
|
|
3857
|
-
if (hasApiErrorBody(error)) {
|
|
3858
|
-
return error;
|
|
3859
|
-
}
|
|
3950
|
+
for (const candidate of errorCandidatesFromUnknown(value)) {
|
|
3951
|
+
if (hasApiErrorBody(candidate)) {
|
|
3952
|
+
return candidate;
|
|
3860
3953
|
}
|
|
3861
3954
|
}
|
|
3862
3955
|
return null;
|
|
3863
3956
|
}
|
|
3864
3957
|
function errorMessageFromUnknown(value) {
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
|
|
3958
|
+
for (const candidate of errorCandidatesFromUnknown(value)) {
|
|
3959
|
+
if (candidate instanceof Error && candidate.message.length > 0) {
|
|
3960
|
+
return candidate.message;
|
|
3961
|
+
}
|
|
3962
|
+
if (typeof candidate === "string" && candidate.length > 0) {
|
|
3963
|
+
return candidate;
|
|
3964
|
+
}
|
|
3870
3965
|
}
|
|
3871
3966
|
return "Spoke Hub client request failed";
|
|
3872
3967
|
}
|
|
3873
3968
|
function classifyClientError(value) {
|
|
3969
|
+
const context = httpContextFromUnknown(value);
|
|
3970
|
+
if (context.status !== void 0) {
|
|
3971
|
+
return "api";
|
|
3972
|
+
}
|
|
3874
3973
|
const message = errorMessageFromUnknown(value).toLowerCase();
|
|
3875
3974
|
if (value instanceof TypeError || message.includes("fetch failed") || message.includes("network") || message.includes("econnrefused") || message.includes("enotfound") || message.includes("etimedout")) {
|
|
3876
3975
|
return "network";
|
|
@@ -3882,12 +3981,19 @@ function classifyClientError(value) {
|
|
|
3882
3981
|
}
|
|
3883
3982
|
function clientErrorFromUnknown(value) {
|
|
3884
3983
|
const body = apiErrorBodyFromUnknown(value);
|
|
3984
|
+
const context = httpContextFromUnknown(value);
|
|
3885
3985
|
if (body) {
|
|
3886
|
-
return new SpokeHubApiError(body, value);
|
|
3986
|
+
return new SpokeHubApiError(body, value, context);
|
|
3887
3987
|
}
|
|
3988
|
+
const statusCode = context.status ? `http_${context.status}` : void 0;
|
|
3888
3989
|
return new SpokeHubClientError({
|
|
3889
3990
|
kind: classifyClientError(value),
|
|
3991
|
+
code: statusCode,
|
|
3890
3992
|
message: errorMessageFromUnknown(value),
|
|
3993
|
+
status: context.status,
|
|
3994
|
+
method: context.method,
|
|
3995
|
+
url: context.url,
|
|
3996
|
+
reason: context.reason,
|
|
3891
3997
|
cause: value
|
|
3892
3998
|
});
|
|
3893
3999
|
}
|