@gethydra/sdk 0.1.36 → 0.1.38
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/dist/index.d.ts +157 -9
- package/dist/index.js +162 -8
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -20523,7 +20523,7 @@ type Customer = components['schemas']['Customer'];
|
|
|
20523
20523
|
type ListParams$o = NonNullable<operations['listCustomers']['parameters']['query']>;
|
|
20524
20524
|
type CreateBody$h = NonNullable<operations['createCustomer']['requestBody']>['content']['application/json'];
|
|
20525
20525
|
type UpdateBody$k = NonNullable<operations['updateCustomer']['requestBody']>['content']['application/json'];
|
|
20526
|
-
type CreateAddressBody$
|
|
20526
|
+
type CreateAddressBody$2 = NonNullable<operations['createCustomerAddress']['requestBody']>['content']['application/json'];
|
|
20527
20527
|
type CreateNoteBody$1 = NonNullable<operations['createCustomerNote']['requestBody']>['content']['application/json'];
|
|
20528
20528
|
declare class CustomersResource {
|
|
20529
20529
|
private client;
|
|
@@ -20538,7 +20538,7 @@ declare class CustomersResource {
|
|
|
20538
20538
|
update(id: string, body: UpdateBody$k): Promise<DataResponse<Customer>>;
|
|
20539
20539
|
delete(id: string): Promise<void>;
|
|
20540
20540
|
listAddresses(customerId: string): Promise<DataResponse<unknown[]>>;
|
|
20541
|
-
createAddress(customerId: string, body: CreateAddressBody$
|
|
20541
|
+
createAddress(customerId: string, body: CreateAddressBody$2): Promise<DataResponse<unknown>>;
|
|
20542
20542
|
listNotes(customerId: string): Promise<DataResponse<unknown[]>>;
|
|
20543
20543
|
createNote(customerId: string, body: CreateNoteBody$1): Promise<DataResponse<unknown>>;
|
|
20544
20544
|
deleteNote(customerId: string, noteId: string): Promise<void>;
|
|
@@ -20856,8 +20856,8 @@ type Company = components['schemas']['Company'];
|
|
|
20856
20856
|
type ListParams$e = NonNullable<operations['listCompanies']['parameters']['query']>;
|
|
20857
20857
|
type CreateBody$a = NonNullable<operations['createCompany']['requestBody']>['content']['application/json'];
|
|
20858
20858
|
type UpdateBody$a = NonNullable<operations['updateCompany']['requestBody']>['content']['application/json'];
|
|
20859
|
-
type CreateAddressBody = NonNullable<operations['createCompanyAddress']['requestBody']>['content']['application/json'];
|
|
20860
|
-
type UpdateAddressBody = NonNullable<operations['updateCompanyAddress']['requestBody']>['content']['application/json'];
|
|
20859
|
+
type CreateAddressBody$1 = NonNullable<operations['createCompanyAddress']['requestBody']>['content']['application/json'];
|
|
20860
|
+
type UpdateAddressBody$1 = NonNullable<operations['updateCompanyAddress']['requestBody']>['content']['application/json'];
|
|
20861
20861
|
type CreateContactBody = NonNullable<operations['createCompanyContact']['requestBody']>['content']['application/json'];
|
|
20862
20862
|
type UpdateContactBody = NonNullable<operations['updateCompanyContact']['requestBody']>['content']['application/json'];
|
|
20863
20863
|
type CreateNoteBody = NonNullable<operations['createCompanyNote']['requestBody']>['content']['application/json'];
|
|
@@ -20874,8 +20874,8 @@ declare class CompaniesResource {
|
|
|
20874
20874
|
update(id: string, body: UpdateBody$a): Promise<DataResponse<Company>>;
|
|
20875
20875
|
delete(id: string): Promise<void>;
|
|
20876
20876
|
listAddresses(companyId: string): Promise<DataResponse<unknown[]>>;
|
|
20877
|
-
createAddress(companyId: string, body: CreateAddressBody): Promise<DataResponse<unknown>>;
|
|
20878
|
-
updateAddress(companyId: string, addressId: string, body: UpdateAddressBody): Promise<DataResponse<unknown>>;
|
|
20877
|
+
createAddress(companyId: string, body: CreateAddressBody$1): Promise<DataResponse<unknown>>;
|
|
20878
|
+
updateAddress(companyId: string, addressId: string, body: UpdateAddressBody$1): Promise<DataResponse<unknown>>;
|
|
20879
20879
|
deleteAddress(companyId: string, addressId: string): Promise<void>;
|
|
20880
20880
|
listContacts(companyId: string): Promise<DataResponse<unknown[]>>;
|
|
20881
20881
|
createContact(companyId: string, body: CreateContactBody): Promise<DataResponse<unknown>>;
|
|
@@ -21139,7 +21139,7 @@ declare class AnalyticsResource {
|
|
|
21139
21139
|
}
|
|
21140
21140
|
|
|
21141
21141
|
type CreditTransaction = NonNullable<operations['issueCustomerCredit']['responses']['201']['content']['application/json']['data']>;
|
|
21142
|
-
type CreditBalance = NonNullable<operations['getCustomerCredit']['responses']['200']['content']['application/json']['data']>;
|
|
21142
|
+
type CreditBalance$1 = NonNullable<operations['getCustomerCredit']['responses']['200']['content']['application/json']['data']>;
|
|
21143
21143
|
type ListParams$6 = NonNullable<operations['listCustomerCreditTransactions']['parameters']['query']>;
|
|
21144
21144
|
type IssueCreditBody = NonNullable<operations['issueCustomerCredit']['requestBody']>['content']['application/json'];
|
|
21145
21145
|
interface LoyaltySummary {
|
|
@@ -21158,7 +21158,7 @@ interface LoyaltySummary {
|
|
|
21158
21158
|
declare class StoreCreditResource {
|
|
21159
21159
|
private client;
|
|
21160
21160
|
constructor(client: Hydra);
|
|
21161
|
-
getBalance(customerId: string): Promise<DataResponse<CreditBalance>>;
|
|
21161
|
+
getBalance(customerId: string): Promise<DataResponse<CreditBalance$1>>;
|
|
21162
21162
|
getLoyalty(customerId: string): Promise<DataResponse<LoyaltySummary>>;
|
|
21163
21163
|
issue(customerId: string, body: IssueCreditBody, options?: ResourceRequestOptions): Promise<DataResponse<CreditTransaction>>;
|
|
21164
21164
|
listTransactions(customerId: string, params?: ListParams$6): Promise<ListResponse<CreditTransaction>>;
|
|
@@ -21573,6 +21573,145 @@ declare class GiftCardsResource {
|
|
|
21573
21573
|
lookup(code: string): Promise<DataResponse<GiftCardLookup>>;
|
|
21574
21574
|
}
|
|
21575
21575
|
|
|
21576
|
+
interface AuthCustomer {
|
|
21577
|
+
id: string;
|
|
21578
|
+
email: string;
|
|
21579
|
+
first_name: string;
|
|
21580
|
+
last_name: string;
|
|
21581
|
+
phone: string | null;
|
|
21582
|
+
locale: string | null;
|
|
21583
|
+
email_verified: boolean;
|
|
21584
|
+
created_at: string;
|
|
21585
|
+
updated_at: string;
|
|
21586
|
+
}
|
|
21587
|
+
interface TokenResponse {
|
|
21588
|
+
access_token: string;
|
|
21589
|
+
refresh_token: string;
|
|
21590
|
+
expires_in: number;
|
|
21591
|
+
customer?: AuthCustomer;
|
|
21592
|
+
}
|
|
21593
|
+
interface MessageResponse {
|
|
21594
|
+
message: string;
|
|
21595
|
+
}
|
|
21596
|
+
interface RegisterBody {
|
|
21597
|
+
email: string;
|
|
21598
|
+
password: string;
|
|
21599
|
+
first_name: string;
|
|
21600
|
+
last_name: string;
|
|
21601
|
+
phone?: string;
|
|
21602
|
+
locale?: string;
|
|
21603
|
+
}
|
|
21604
|
+
interface LoginBody {
|
|
21605
|
+
email: string;
|
|
21606
|
+
password: string;
|
|
21607
|
+
}
|
|
21608
|
+
declare class AuthResource {
|
|
21609
|
+
private client;
|
|
21610
|
+
constructor(client: Hydra);
|
|
21611
|
+
/** Register a new customer account. Returns access + refresh tokens. */
|
|
21612
|
+
register(body: RegisterBody): Promise<TokenResponse>;
|
|
21613
|
+
/** Log in with email and password. Returns access + refresh tokens. */
|
|
21614
|
+
login(body: LoginBody): Promise<TokenResponse>;
|
|
21615
|
+
/** Exchange a refresh token for new access + refresh tokens (single-use rotation). */
|
|
21616
|
+
refreshToken(refreshToken: string): Promise<TokenResponse>;
|
|
21617
|
+
/** Invalidate a refresh token. Idempotent — succeeds even if already invalidated. */
|
|
21618
|
+
logout(refreshToken: string): Promise<void>;
|
|
21619
|
+
/** Request a password reset email. Always returns a generic message (prevents enumeration). */
|
|
21620
|
+
forgotPassword(email: string): Promise<MessageResponse>;
|
|
21621
|
+
/** Reset password using a token from the reset email. Invalidates all sessions. */
|
|
21622
|
+
resetPassword(token: string, password: string): Promise<MessageResponse>;
|
|
21623
|
+
/** Verify a customer's email using the token from the verification email. */
|
|
21624
|
+
verifyEmail(token: string): Promise<MessageResponse>;
|
|
21625
|
+
}
|
|
21626
|
+
|
|
21627
|
+
interface UpdateProfileBody {
|
|
21628
|
+
first_name?: string;
|
|
21629
|
+
last_name?: string;
|
|
21630
|
+
phone?: string | null;
|
|
21631
|
+
locale?: string | null;
|
|
21632
|
+
}
|
|
21633
|
+
interface ChangePasswordBody {
|
|
21634
|
+
current_password: string;
|
|
21635
|
+
new_password: string;
|
|
21636
|
+
}
|
|
21637
|
+
interface CreateAddressBody {
|
|
21638
|
+
first_name?: string | null;
|
|
21639
|
+
last_name?: string | null;
|
|
21640
|
+
company?: string | null;
|
|
21641
|
+
line1: string;
|
|
21642
|
+
line2?: string | null;
|
|
21643
|
+
city: string;
|
|
21644
|
+
state?: string | null;
|
|
21645
|
+
postal_code?: string | null;
|
|
21646
|
+
country: string;
|
|
21647
|
+
phone?: string | null;
|
|
21648
|
+
is_default?: boolean;
|
|
21649
|
+
}
|
|
21650
|
+
interface UpdateAddressBody {
|
|
21651
|
+
first_name?: string | null;
|
|
21652
|
+
last_name?: string | null;
|
|
21653
|
+
company?: string | null;
|
|
21654
|
+
line1?: string;
|
|
21655
|
+
line2?: string | null;
|
|
21656
|
+
city?: string;
|
|
21657
|
+
state?: string | null;
|
|
21658
|
+
postal_code?: string | null;
|
|
21659
|
+
country?: string;
|
|
21660
|
+
phone?: string | null;
|
|
21661
|
+
is_default?: boolean;
|
|
21662
|
+
}
|
|
21663
|
+
interface MeOrdersParams {
|
|
21664
|
+
limit?: number;
|
|
21665
|
+
cursor?: string;
|
|
21666
|
+
sort?: 'created_at';
|
|
21667
|
+
order?: 'asc' | 'desc';
|
|
21668
|
+
}
|
|
21669
|
+
interface CreditBalance {
|
|
21670
|
+
balance: number;
|
|
21671
|
+
available: number;
|
|
21672
|
+
pending: number;
|
|
21673
|
+
currency: string;
|
|
21674
|
+
}
|
|
21675
|
+
/**
|
|
21676
|
+
* Customer self-service resource for `/v1/me/*` endpoints.
|
|
21677
|
+
* Methods use the client-level customer token by default.
|
|
21678
|
+
* Pass an explicit `accessToken` to override (useful server-side).
|
|
21679
|
+
*/
|
|
21680
|
+
declare class MeResource {
|
|
21681
|
+
private client;
|
|
21682
|
+
constructor(client: Hydra);
|
|
21683
|
+
private opts;
|
|
21684
|
+
/** Get the authenticated customer's profile. */
|
|
21685
|
+
getProfile(accessToken?: string): Promise<DataResponse<unknown>>;
|
|
21686
|
+
/** Update profile fields (first_name, last_name, phone, locale). */
|
|
21687
|
+
updateProfile(body: UpdateProfileBody, accessToken?: string): Promise<DataResponse<unknown>>;
|
|
21688
|
+
/** Change password. Invalidates all sessions and returns new tokens. */
|
|
21689
|
+
changePassword(body: ChangePasswordBody, accessToken?: string): Promise<TokenResponse>;
|
|
21690
|
+
/** List the customer's order history. */
|
|
21691
|
+
listOrders(params?: MeOrdersParams, accessToken?: string): Promise<ListResponse<unknown>>;
|
|
21692
|
+
/** List the customer's addresses. */
|
|
21693
|
+
listAddresses(accessToken?: string): Promise<DataResponse<unknown[]>>;
|
|
21694
|
+
/** Create a new address. */
|
|
21695
|
+
createAddress(body: CreateAddressBody, accessToken?: string): Promise<DataResponse<unknown>>;
|
|
21696
|
+
/** Update an existing address. */
|
|
21697
|
+
updateAddress(id: string, body: UpdateAddressBody, accessToken?: string): Promise<DataResponse<unknown>>;
|
|
21698
|
+
/** Delete an address. */
|
|
21699
|
+
deleteAddress(id: string, accessToken?: string): Promise<void>;
|
|
21700
|
+
/** Get store credit balance breakdown. */
|
|
21701
|
+
getCredit(accessToken?: string): Promise<DataResponse<CreditBalance>>;
|
|
21702
|
+
/** List store credit transactions. */
|
|
21703
|
+
listCreditTransactions(params?: {
|
|
21704
|
+
limit?: number;
|
|
21705
|
+
cursor?: string;
|
|
21706
|
+
sort?: string;
|
|
21707
|
+
order?: 'asc' | 'desc';
|
|
21708
|
+
}, accessToken?: string): Promise<ListResponse<unknown>>;
|
|
21709
|
+
/** List the customer's returns. */
|
|
21710
|
+
listReturns(accessToken?: string): Promise<DataResponse<unknown[]>>;
|
|
21711
|
+
/** Get active membership. */
|
|
21712
|
+
getMembership(accessToken?: string): Promise<DataResponse<unknown>>;
|
|
21713
|
+
}
|
|
21714
|
+
|
|
21576
21715
|
interface AppInfo {
|
|
21577
21716
|
/** Integration/plugin name (e.g. "MyShopTheme") */
|
|
21578
21717
|
name: string;
|
|
@@ -21612,6 +21751,13 @@ declare class Hydra {
|
|
|
21612
21751
|
readonly timeout: number;
|
|
21613
21752
|
readonly maxNetworkRetries: number;
|
|
21614
21753
|
readonly appInfo?: AppInfo;
|
|
21754
|
+
private _customerToken;
|
|
21755
|
+
/** Current customer access token, or null if not set. */
|
|
21756
|
+
get customerToken(): string | null;
|
|
21757
|
+
/** Set a customer access token (JWT). Subsequent requests include `Authorization: Bearer {token}`. */
|
|
21758
|
+
setCustomerToken(token: string): void;
|
|
21759
|
+
/** Clear the customer access token. */
|
|
21760
|
+
clearCustomerToken(): void;
|
|
21615
21761
|
readonly products: ProductsResource;
|
|
21616
21762
|
readonly variants: VariantsResource;
|
|
21617
21763
|
readonly collections: CollectionsResource;
|
|
@@ -21657,6 +21803,8 @@ declare class Hydra {
|
|
|
21657
21803
|
readonly bookings: BookingsResource;
|
|
21658
21804
|
readonly lookbooks: LookbooksResource;
|
|
21659
21805
|
readonly giftCards: GiftCardsResource;
|
|
21806
|
+
readonly auth: AuthResource;
|
|
21807
|
+
readonly me: MeResource;
|
|
21660
21808
|
constructor(config: HydraConfig);
|
|
21661
21809
|
request<T>(method: string, path: string, options?: RequestOptions): Promise<T>;
|
|
21662
21810
|
/** Multipart upload for file-based endpoints (e.g. images) */
|
|
@@ -21738,4 +21886,4 @@ declare class HydraIdempotencyError extends HydraError {
|
|
|
21738
21886
|
constructor(body: HydraErrorBody, headers: Headers);
|
|
21739
21887
|
}
|
|
21740
21888
|
|
|
21741
|
-
export { AddressesResource, type AnalyticsActionItems$1 as AnalyticsActionItems, type AnalyticsOrdersSeries$1 as AnalyticsOrdersSeries, AnalyticsResource, type AnalyticsSummary$1 as AnalyticsSummary, type AnalyticsTimeSeries$1 as AnalyticsTimeSeries, type AnalyticsTopProduct$1 as AnalyticsTopProduct, type AppInfo, type Appointment$1 as Appointment, type AvailabilityOverride$1 as AvailabilityOverride, BookingsResource, type Cart$1 as Cart, type CartItem, CartResource, type Channel$1 as Channel, ChannelsResource, type CheckoutCreate$1 as CheckoutCreate, type CheckoutGet$1 as CheckoutGet, type CheckoutListItem$1 as CheckoutListItem, CheckoutResource, CheckoutsResource, type Collection$1 as Collection, CollectionsResource, CompaniesResource, type Company$1 as Company, ContentCategoriesResource, type ContentCategory$1 as ContentCategory, type CreateGiftCardBody, type Customer$1 as Customer, type CustomerGroup$1 as CustomerGroup, CustomerGroupsResource, type CustomerMembership$1 as CustomerMembership, type CustomerPhoto$1 as CustomerPhoto, CustomerPhotosResource, CustomersResource, type DataResponse, type DayAvailability$1 as DayAvailability, type Discount$1 as Discount, DiscountsResource, type DraftOrder$1 as DraftOrder, DraftOrdersResource, type ExchangeRate$1 as ExchangeRate, ExchangeRatesResource, type Fulfillment$1 as Fulfillment, type FulfillmentOrder$2 as FulfillmentOrder, FulfillmentOrdersResource, FulfillmentsResource, type GenerateVariantsResult$1 as GenerateVariantsResult, type GiftCard, type GiftCardConvertResult, type CreditDebitBody as GiftCardCreditDebitBody, type GiftCardLookup, type GiftCardTransaction, GiftCardsResource, Hydra, HydraAuthenticationError, type HydraConfig, HydraConnectionError, HydraError, type HydraErrorBody, HydraIdempotencyError, HydraNotFoundError, HydraPermissionError, HydraRateLimitError, HydraValidationError, type Image$2 as Image, ImagesResource, IntegrationsResource, type InventoryLevel$1 as InventoryLevel, InventoryResource, type ListGiftCardTransactionsParams, type ListGiftCardsParams, type ListResponse, type Location$1 as Location, LocationsResource, type Lookbook$1 as Lookbook, type LookbookTag$1 as LookbookTag, LookbooksResource, type LoyaltySummary, type MembershipPlan$1 as MembershipPlan, MembershipPlansResource, MetafieldsResource, type NotificationLog$1 as NotificationLog, NotificationsResource, type Order$2 as Order, OrdersResource, type PaginateOptions, type Pagination, type PosAnalyticsDashboard, type Post$1 as Post, PostsResource, type Product$1 as Product, type ProductStats$1 as ProductStats, ProductsResource, type Promotion$1 as Promotion, PromotionsResource, type PurchaseOrder$1 as PurchaseOrder, PurchaseOrdersResource, type Redirect$1 as Redirect, RedirectsResource, type Refund$1 as Refund, RefundsResource, type RequestOptions, type ResourceRequestOptions, type Return$1 as Return, ReturnsResource, SearchResource, type ShippingRate$1 as ShippingRate, ShippingResource, type ShippingZone$1 as ShippingZone, type Slot, type Store$1 as Store, StoreCreditResource, StoreResource, type SuggestedSlot$1 as SuggestedSlot, type Tag$1 as Tag, TagsResource, type TaxExemption$1 as TaxExemption, type TaxGroup$1 as TaxGroup, type TaxRate$1 as TaxRate, TaxResource, type UpdateGiftCardBody, type Variant$2 as Variant, type VariantPrice$1 as VariantPrice, VariantsResource, type Webhook$1 as Webhook, WebhooksResource, paginate, toArray };
|
|
21889
|
+
export { AddressesResource, type AnalyticsActionItems$1 as AnalyticsActionItems, type AnalyticsOrdersSeries$1 as AnalyticsOrdersSeries, AnalyticsResource, type AnalyticsSummary$1 as AnalyticsSummary, type AnalyticsTimeSeries$1 as AnalyticsTimeSeries, type AnalyticsTopProduct$1 as AnalyticsTopProduct, type AppInfo, type Appointment$1 as Appointment, type AuthCustomer, AuthResource, type AvailabilityOverride$1 as AvailabilityOverride, BookingsResource, type Cart$1 as Cart, type CartItem, CartResource, type ChangePasswordBody, type Channel$1 as Channel, ChannelsResource, type CheckoutCreate$1 as CheckoutCreate, type CheckoutGet$1 as CheckoutGet, type CheckoutListItem$1 as CheckoutListItem, CheckoutResource, CheckoutsResource, type Collection$1 as Collection, CollectionsResource, CompaniesResource, type Company$1 as Company, ContentCategoriesResource, type ContentCategory$1 as ContentCategory, type CreateGiftCardBody, type CreditBalance, type Customer$1 as Customer, type CustomerGroup$1 as CustomerGroup, CustomerGroupsResource, type CustomerMembership$1 as CustomerMembership, type CustomerPhoto$1 as CustomerPhoto, CustomerPhotosResource, CustomersResource, type DataResponse, type DayAvailability$1 as DayAvailability, type Discount$1 as Discount, DiscountsResource, type DraftOrder$1 as DraftOrder, DraftOrdersResource, type ExchangeRate$1 as ExchangeRate, ExchangeRatesResource, type Fulfillment$1 as Fulfillment, type FulfillmentOrder$2 as FulfillmentOrder, FulfillmentOrdersResource, FulfillmentsResource, type GenerateVariantsResult$1 as GenerateVariantsResult, type GiftCard, type GiftCardConvertResult, type CreditDebitBody as GiftCardCreditDebitBody, type GiftCardLookup, type GiftCardTransaction, GiftCardsResource, Hydra, HydraAuthenticationError, type HydraConfig, HydraConnectionError, HydraError, type HydraErrorBody, HydraIdempotencyError, HydraNotFoundError, HydraPermissionError, HydraRateLimitError, HydraValidationError, type Image$2 as Image, ImagesResource, IntegrationsResource, type InventoryLevel$1 as InventoryLevel, InventoryResource, type ListGiftCardTransactionsParams, type ListGiftCardsParams, type ListResponse, type Location$1 as Location, LocationsResource, type LoginBody, type Lookbook$1 as Lookbook, type LookbookTag$1 as LookbookTag, LookbooksResource, type LoyaltySummary, type CreateAddressBody as MeCreateAddressBody, type MeOrdersParams, MeResource, type UpdateAddressBody as MeUpdateAddressBody, type MembershipPlan$1 as MembershipPlan, MembershipPlansResource, type MessageResponse, MetafieldsResource, type NotificationLog$1 as NotificationLog, NotificationsResource, type Order$2 as Order, OrdersResource, type PaginateOptions, type Pagination, type PosAnalyticsDashboard, type Post$1 as Post, PostsResource, type Product$1 as Product, type ProductStats$1 as ProductStats, ProductsResource, type Promotion$1 as Promotion, PromotionsResource, type PurchaseOrder$1 as PurchaseOrder, PurchaseOrdersResource, type Redirect$1 as Redirect, RedirectsResource, type Refund$1 as Refund, RefundsResource, type RegisterBody, type RequestOptions, type ResourceRequestOptions, type Return$1 as Return, ReturnsResource, SearchResource, type ShippingRate$1 as ShippingRate, ShippingResource, type ShippingZone$1 as ShippingZone, type Slot, type Store$1 as Store, StoreCreditResource, StoreResource, type SuggestedSlot$1 as SuggestedSlot, type Tag$1 as Tag, TagsResource, type TaxExemption$1 as TaxExemption, type TaxGroup$1 as TaxGroup, type TaxRate$1 as TaxRate, TaxResource, type TokenResponse, type UpdateGiftCardBody, type UpdateProfileBody, type Variant$2 as Variant, type VariantPrice$1 as VariantPrice, VariantsResource, type Webhook$1 as Webhook, WebhooksResource, paginate, toArray };
|
package/dist/index.js
CHANGED
|
@@ -1807,6 +1807,133 @@ var GiftCardsResource = class {
|
|
|
1807
1807
|
}
|
|
1808
1808
|
};
|
|
1809
1809
|
|
|
1810
|
+
// src/resources/auth.ts
|
|
1811
|
+
var AuthResource = class {
|
|
1812
|
+
constructor(client) {
|
|
1813
|
+
this.client = client;
|
|
1814
|
+
}
|
|
1815
|
+
client;
|
|
1816
|
+
/** Register a new customer account. Returns access + refresh tokens. */
|
|
1817
|
+
async register(body) {
|
|
1818
|
+
return this.client.request("POST", "/v1/auth/register", { body });
|
|
1819
|
+
}
|
|
1820
|
+
/** Log in with email and password. Returns access + refresh tokens. */
|
|
1821
|
+
async login(body) {
|
|
1822
|
+
return this.client.request("POST", "/v1/auth/login", { body });
|
|
1823
|
+
}
|
|
1824
|
+
/** Exchange a refresh token for new access + refresh tokens (single-use rotation). */
|
|
1825
|
+
async refreshToken(refreshToken) {
|
|
1826
|
+
return this.client.request("POST", "/v1/auth/token", {
|
|
1827
|
+
body: { refresh_token: refreshToken }
|
|
1828
|
+
});
|
|
1829
|
+
}
|
|
1830
|
+
/** Invalidate a refresh token. Idempotent — succeeds even if already invalidated. */
|
|
1831
|
+
async logout(refreshToken) {
|
|
1832
|
+
return this.client.request("POST", "/v1/auth/logout", {
|
|
1833
|
+
body: { refresh_token: refreshToken }
|
|
1834
|
+
});
|
|
1835
|
+
}
|
|
1836
|
+
/** Request a password reset email. Always returns a generic message (prevents enumeration). */
|
|
1837
|
+
async forgotPassword(email) {
|
|
1838
|
+
return this.client.request("POST", "/v1/auth/forgot-password", {
|
|
1839
|
+
body: { email }
|
|
1840
|
+
});
|
|
1841
|
+
}
|
|
1842
|
+
/** Reset password using a token from the reset email. Invalidates all sessions. */
|
|
1843
|
+
async resetPassword(token, password) {
|
|
1844
|
+
return this.client.request("POST", "/v1/auth/reset-password", {
|
|
1845
|
+
body: { token, password }
|
|
1846
|
+
});
|
|
1847
|
+
}
|
|
1848
|
+
/** Verify a customer's email using the token from the verification email. */
|
|
1849
|
+
async verifyEmail(token) {
|
|
1850
|
+
return this.client.request("POST", "/v1/auth/verify-email", {
|
|
1851
|
+
body: { token }
|
|
1852
|
+
});
|
|
1853
|
+
}
|
|
1854
|
+
};
|
|
1855
|
+
|
|
1856
|
+
// src/resources/me.ts
|
|
1857
|
+
var MeResource = class {
|
|
1858
|
+
constructor(client) {
|
|
1859
|
+
this.client = client;
|
|
1860
|
+
}
|
|
1861
|
+
client;
|
|
1862
|
+
opts(accessToken, extra) {
|
|
1863
|
+
const token = accessToken ?? this.client.customerToken;
|
|
1864
|
+
if (!token) {
|
|
1865
|
+
throw new Error(
|
|
1866
|
+
"Customer access token required. Pass accessToken or call hydra.setCustomerToken()."
|
|
1867
|
+
);
|
|
1868
|
+
}
|
|
1869
|
+
return {
|
|
1870
|
+
...extra,
|
|
1871
|
+
headers: {
|
|
1872
|
+
Authorization: `Bearer ${token}`,
|
|
1873
|
+
...extra?.headers
|
|
1874
|
+
}
|
|
1875
|
+
};
|
|
1876
|
+
}
|
|
1877
|
+
/** Get the authenticated customer's profile. */
|
|
1878
|
+
async getProfile(accessToken) {
|
|
1879
|
+
return this.client.request("GET", "/v1/me", this.opts(accessToken));
|
|
1880
|
+
}
|
|
1881
|
+
/** Update profile fields (first_name, last_name, phone, locale). */
|
|
1882
|
+
async updateProfile(body, accessToken) {
|
|
1883
|
+
return this.client.request("PATCH", "/v1/me", this.opts(accessToken, { body }));
|
|
1884
|
+
}
|
|
1885
|
+
/** Change password. Invalidates all sessions and returns new tokens. */
|
|
1886
|
+
async changePassword(body, accessToken) {
|
|
1887
|
+
return this.client.request("POST", "/v1/me/password", this.opts(accessToken, { body }));
|
|
1888
|
+
}
|
|
1889
|
+
/** List the customer's order history. */
|
|
1890
|
+
async listOrders(params, accessToken) {
|
|
1891
|
+
return this.client.request("GET", "/v1/me/orders", this.opts(accessToken, {
|
|
1892
|
+
params
|
|
1893
|
+
}));
|
|
1894
|
+
}
|
|
1895
|
+
/** List the customer's addresses. */
|
|
1896
|
+
async listAddresses(accessToken) {
|
|
1897
|
+
return this.client.request("GET", "/v1/me/addresses", this.opts(accessToken));
|
|
1898
|
+
}
|
|
1899
|
+
/** Create a new address. */
|
|
1900
|
+
async createAddress(body, accessToken) {
|
|
1901
|
+
return this.client.request("POST", "/v1/me/addresses", this.opts(accessToken, { body }));
|
|
1902
|
+
}
|
|
1903
|
+
/** Update an existing address. */
|
|
1904
|
+
async updateAddress(id, body, accessToken) {
|
|
1905
|
+
return this.client.request(
|
|
1906
|
+
"PATCH",
|
|
1907
|
+
`/v1/me/addresses/${id}`,
|
|
1908
|
+
this.opts(accessToken, { body })
|
|
1909
|
+
);
|
|
1910
|
+
}
|
|
1911
|
+
/** Delete an address. */
|
|
1912
|
+
async deleteAddress(id, accessToken) {
|
|
1913
|
+
return this.client.request("DELETE", `/v1/me/addresses/${id}`, this.opts(accessToken));
|
|
1914
|
+
}
|
|
1915
|
+
/** Get store credit balance breakdown. */
|
|
1916
|
+
async getCredit(accessToken) {
|
|
1917
|
+
return this.client.request("GET", "/v1/me/credit", this.opts(accessToken));
|
|
1918
|
+
}
|
|
1919
|
+
/** List store credit transactions. */
|
|
1920
|
+
async listCreditTransactions(params, accessToken) {
|
|
1921
|
+
return this.client.request(
|
|
1922
|
+
"GET",
|
|
1923
|
+
"/v1/me/credit/transactions",
|
|
1924
|
+
this.opts(accessToken, { params })
|
|
1925
|
+
);
|
|
1926
|
+
}
|
|
1927
|
+
/** List the customer's returns. */
|
|
1928
|
+
async listReturns(accessToken) {
|
|
1929
|
+
return this.client.request("GET", "/v1/me/returns", this.opts(accessToken));
|
|
1930
|
+
}
|
|
1931
|
+
/** Get active membership. */
|
|
1932
|
+
async getMembership(accessToken) {
|
|
1933
|
+
return this.client.request("GET", "/v1/me/membership", this.opts(accessToken));
|
|
1934
|
+
}
|
|
1935
|
+
};
|
|
1936
|
+
|
|
1810
1937
|
// src/client.ts
|
|
1811
1938
|
var SDK_VERSION = "0.1.0";
|
|
1812
1939
|
var INITIAL_RETRY_DELAY = 0.5;
|
|
@@ -1837,6 +1964,19 @@ var Hydra = class {
|
|
|
1837
1964
|
timeout;
|
|
1838
1965
|
maxNetworkRetries;
|
|
1839
1966
|
appInfo;
|
|
1967
|
+
_customerToken = null;
|
|
1968
|
+
/** Current customer access token, or null if not set. */
|
|
1969
|
+
get customerToken() {
|
|
1970
|
+
return this._customerToken;
|
|
1971
|
+
}
|
|
1972
|
+
/** Set a customer access token (JWT). Subsequent requests include `Authorization: Bearer {token}`. */
|
|
1973
|
+
setCustomerToken(token) {
|
|
1974
|
+
this._customerToken = token;
|
|
1975
|
+
}
|
|
1976
|
+
/** Clear the customer access token. */
|
|
1977
|
+
clearCustomerToken() {
|
|
1978
|
+
this._customerToken = null;
|
|
1979
|
+
}
|
|
1840
1980
|
// P1: Storefront essentials
|
|
1841
1981
|
products = new ProductsResource(this);
|
|
1842
1982
|
variants = new VariantsResource(this);
|
|
@@ -1893,6 +2033,9 @@ var Hydra = class {
|
|
|
1893
2033
|
lookbooks = new LookbooksResource(this);
|
|
1894
2034
|
// P11: Gift Cards
|
|
1895
2035
|
giftCards = new GiftCardsResource(this);
|
|
2036
|
+
// P12: Customer Auth
|
|
2037
|
+
auth = new AuthResource(this);
|
|
2038
|
+
me = new MeResource(this);
|
|
1896
2039
|
constructor(config) {
|
|
1897
2040
|
for (const key of Object.keys(config)) {
|
|
1898
2041
|
if (!VALID_CONFIG_KEYS.has(key)) {
|
|
@@ -1989,10 +2132,15 @@ var Hydra = class {
|
|
|
1989
2132
|
}
|
|
1990
2133
|
}
|
|
1991
2134
|
const headers = {
|
|
1992
|
-
|
|
1993
|
-
"User-Agent": this.getUserAgent()
|
|
1994
|
-
...options?.headers
|
|
2135
|
+
"X-API-Key": this.apiKey,
|
|
2136
|
+
"User-Agent": this.getUserAgent()
|
|
1995
2137
|
};
|
|
2138
|
+
if (this._customerToken) {
|
|
2139
|
+
headers["Authorization"] = `Bearer ${this._customerToken}`;
|
|
2140
|
+
}
|
|
2141
|
+
if (options?.headers) {
|
|
2142
|
+
Object.assign(headers, options.headers);
|
|
2143
|
+
}
|
|
1996
2144
|
if (options?.body) {
|
|
1997
2145
|
headers["Content-Type"] = "application/json";
|
|
1998
2146
|
}
|
|
@@ -2010,13 +2158,17 @@ var Hydra = class {
|
|
|
2010
2158
|
executeUpload(path, formData, options) {
|
|
2011
2159
|
const url = new URL(path, this.baseUrl);
|
|
2012
2160
|
const { signal, cleanup } = this.buildSignal(options);
|
|
2161
|
+
const headers = {
|
|
2162
|
+
"X-API-Key": this.apiKey,
|
|
2163
|
+
"User-Agent": this.getUserAgent()
|
|
2164
|
+
// No Content-Type — let the runtime set the multipart boundary
|
|
2165
|
+
};
|
|
2166
|
+
if (this._customerToken) {
|
|
2167
|
+
headers["Authorization"] = `Bearer ${this._customerToken}`;
|
|
2168
|
+
}
|
|
2013
2169
|
return fetch(url.toString(), {
|
|
2014
2170
|
method: "POST",
|
|
2015
|
-
headers
|
|
2016
|
-
Authorization: `Bearer ${this.apiKey}`,
|
|
2017
|
-
"User-Agent": this.getUserAgent()
|
|
2018
|
-
// No Content-Type — let the runtime set the multipart boundary
|
|
2019
|
-
},
|
|
2171
|
+
headers,
|
|
2020
2172
|
body: formData,
|
|
2021
2173
|
signal
|
|
2022
2174
|
}).finally(cleanup);
|
|
@@ -2101,6 +2253,7 @@ var Hydra = class {
|
|
|
2101
2253
|
export {
|
|
2102
2254
|
AddressesResource,
|
|
2103
2255
|
AnalyticsResource,
|
|
2256
|
+
AuthResource,
|
|
2104
2257
|
BookingsResource,
|
|
2105
2258
|
CartResource,
|
|
2106
2259
|
ChannelsResource,
|
|
@@ -2132,6 +2285,7 @@ export {
|
|
|
2132
2285
|
InventoryResource,
|
|
2133
2286
|
LocationsResource,
|
|
2134
2287
|
LookbooksResource,
|
|
2288
|
+
MeResource,
|
|
2135
2289
|
MembershipPlansResource,
|
|
2136
2290
|
MetafieldsResource,
|
|
2137
2291
|
NotificationsResource,
|