@gethydra/sdk 0.1.58 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +105 -1
- package/dist/index.js +53 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -23811,6 +23811,109 @@ declare class DirectoryResource {
|
|
|
23811
23811
|
}>>;
|
|
23812
23812
|
}
|
|
23813
23813
|
|
|
23814
|
+
interface GeoCountrySummary {
|
|
23815
|
+
code: string;
|
|
23816
|
+
name: string;
|
|
23817
|
+
region_count: number;
|
|
23818
|
+
}
|
|
23819
|
+
interface GeoCountry {
|
|
23820
|
+
code: string;
|
|
23821
|
+
name: string;
|
|
23822
|
+
subdivisions: string[];
|
|
23823
|
+
region_count: number;
|
|
23824
|
+
}
|
|
23825
|
+
interface GeoRegion {
|
|
23826
|
+
slug: string;
|
|
23827
|
+
name: string;
|
|
23828
|
+
country_code: string;
|
|
23829
|
+
parent: string;
|
|
23830
|
+
type: string;
|
|
23831
|
+
}
|
|
23832
|
+
interface ListGeoRegionsParams {
|
|
23833
|
+
country?: string;
|
|
23834
|
+
parent?: string;
|
|
23835
|
+
type?: string;
|
|
23836
|
+
}
|
|
23837
|
+
interface GeoOutcode {
|
|
23838
|
+
outcode: string;
|
|
23839
|
+
area: string;
|
|
23840
|
+
latitude: number;
|
|
23841
|
+
longitude: number;
|
|
23842
|
+
postcode_count: number;
|
|
23843
|
+
county?: string;
|
|
23844
|
+
region?: string;
|
|
23845
|
+
country?: string;
|
|
23846
|
+
}
|
|
23847
|
+
interface ListGeoOutcodesParams {
|
|
23848
|
+
area?: string;
|
|
23849
|
+
country?: string;
|
|
23850
|
+
q?: string;
|
|
23851
|
+
}
|
|
23852
|
+
interface GeoPostcode {
|
|
23853
|
+
postcode: string;
|
|
23854
|
+
outcode: string;
|
|
23855
|
+
latitude: number;
|
|
23856
|
+
longitude: number;
|
|
23857
|
+
county?: string;
|
|
23858
|
+
district?: string;
|
|
23859
|
+
region?: string;
|
|
23860
|
+
country?: string;
|
|
23861
|
+
}
|
|
23862
|
+
interface GeoCity {
|
|
23863
|
+
slug: string;
|
|
23864
|
+
name: string;
|
|
23865
|
+
region_slug: string;
|
|
23866
|
+
country_code: string;
|
|
23867
|
+
latitude: number;
|
|
23868
|
+
longitude: number;
|
|
23869
|
+
postcode_area: string;
|
|
23870
|
+
}
|
|
23871
|
+
interface ListGeoCitiesParams {
|
|
23872
|
+
region?: string;
|
|
23873
|
+
country?: string;
|
|
23874
|
+
q?: string;
|
|
23875
|
+
}
|
|
23876
|
+
declare class GeoResource {
|
|
23877
|
+
private client;
|
|
23878
|
+
constructor(client: Hydra);
|
|
23879
|
+
/** List all supported countries with region counts. */
|
|
23880
|
+
countries(): Promise<{
|
|
23881
|
+
data: GeoCountrySummary[];
|
|
23882
|
+
}>;
|
|
23883
|
+
/** Get a single country by ISO 3166-1 alpha-2 code. */
|
|
23884
|
+
country(code: string): Promise<{
|
|
23885
|
+
data: GeoCountry;
|
|
23886
|
+
}>;
|
|
23887
|
+
/** List regions, optionally filtered by country, parent subdivision, or type. */
|
|
23888
|
+
regions(params?: ListGeoRegionsParams): Promise<{
|
|
23889
|
+
data: GeoRegion[];
|
|
23890
|
+
}>;
|
|
23891
|
+
/** Get a single region by slug. */
|
|
23892
|
+
region(slug: string): Promise<{
|
|
23893
|
+
data: GeoRegion;
|
|
23894
|
+
}>;
|
|
23895
|
+
/** List postcode outcodes (districts), filtered by area, country, or prefix. At least one filter required. */
|
|
23896
|
+
outcodes(params: ListGeoOutcodesParams): Promise<{
|
|
23897
|
+
data: GeoOutcode[];
|
|
23898
|
+
}>;
|
|
23899
|
+
/** Get a single outcode by code (e.g. 'S40', 'LE1'). */
|
|
23900
|
+
outcode(code: string): Promise<{
|
|
23901
|
+
data: GeoOutcode;
|
|
23902
|
+
}>;
|
|
23903
|
+
/** Lookup a full UK postcode (e.g. 'S40 1AB'). Returns coordinates, county, district, region. */
|
|
23904
|
+
postcode(code: string): Promise<{
|
|
23905
|
+
data: GeoPostcode;
|
|
23906
|
+
}>;
|
|
23907
|
+
/** List cities/towns, filtered by region slug, country code, or name prefix. At least one filter required. */
|
|
23908
|
+
cities(params: ListGeoCitiesParams): Promise<{
|
|
23909
|
+
data: GeoCity[];
|
|
23910
|
+
}>;
|
|
23911
|
+
/** Get a single city/town by slug. */
|
|
23912
|
+
city(slug: string): Promise<{
|
|
23913
|
+
data: GeoCity;
|
|
23914
|
+
}>;
|
|
23915
|
+
}
|
|
23916
|
+
|
|
23814
23917
|
interface AppInfo {
|
|
23815
23918
|
/** Integration/plugin name (e.g. "MyShopTheme") */
|
|
23816
23919
|
name: string;
|
|
@@ -23909,6 +24012,7 @@ declare class Hydra {
|
|
|
23909
24012
|
readonly directory: DirectoryResource;
|
|
23910
24013
|
readonly directoryCategories: DirectoryCategoriesResource;
|
|
23911
24014
|
readonly directoryTiers: DirectoryTiersResource;
|
|
24015
|
+
readonly geo: GeoResource;
|
|
23912
24016
|
constructor(config: HydraConfig);
|
|
23913
24017
|
request<T>(method: string, path: string, options?: RequestOptions): Promise<T>;
|
|
23914
24018
|
/** Multipart upload for file-based endpoints (e.g. images) */
|
|
@@ -23990,4 +24094,4 @@ declare class HydraIdempotencyError extends HydraError {
|
|
|
23990
24094
|
constructor(body: HydraErrorBody, headers: Headers);
|
|
23991
24095
|
}
|
|
23992
24096
|
|
|
23993
|
-
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 ClaimListingBody, type Collection$1 as Collection, CollectionsResource, CompaniesResource, type Company$1 as Company, ContentCategoriesResource, type ContentCategory$1 as ContentCategory, type CreateDirectoryCategoryBody, type CreateDirectoryListingBody, type CreateDirectoryTierBody, 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, DirectoryCategoriesResource, type DirectoryCategory, type DirectoryClaim, type DirectoryListing, DirectoryResource, type DirectorySettings, type DirectoryTier, type DirectoryTierRule, DirectoryTiersResource, type Discount$1 as Discount, DiscountsResource, type DraftOrder$1 as DraftOrder, DraftOrdersResource, type ExchangeRate$1 as ExchangeRate, ExchangeRatesResource, type FormDefinition$1 as FormDefinition, type FormField$1 as FormField, type FormFieldPublic, type FormPublic$1 as FormPublic, type FormSubmission$1 as FormSubmission, FormSubmissionsResource, FormsResource, 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 ListDirectoryListingsParams, 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 ReorderDirectoryCategoriesBody, type ReorderDirectoryTiersBody, 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 UpdateDirectoryCategoryBody, type UpdateDirectoryListingBody, type UpdateDirectorySettingsBody, type UpdateDirectoryTierBody, type UpdateGiftCardBody, type UpdateProfileBody, type Variant$2 as Variant, type VariantPrice$1 as VariantPrice, VariantsResource, type Webhook$1 as Webhook, WebhooksResource, paginate, toArray };
|
|
24097
|
+
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 ClaimListingBody, type Collection$1 as Collection, CollectionsResource, CompaniesResource, type Company$1 as Company, ContentCategoriesResource, type ContentCategory$1 as ContentCategory, type CreateDirectoryCategoryBody, type CreateDirectoryListingBody, type CreateDirectoryTierBody, 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, DirectoryCategoriesResource, type DirectoryCategory, type DirectoryClaim, type DirectoryListing, DirectoryResource, type DirectorySettings, type DirectoryTier, type DirectoryTierRule, DirectoryTiersResource, type Discount$1 as Discount, DiscountsResource, type DraftOrder$1 as DraftOrder, DraftOrdersResource, type ExchangeRate$1 as ExchangeRate, ExchangeRatesResource, type FormDefinition$1 as FormDefinition, type FormField$1 as FormField, type FormFieldPublic, type FormPublic$1 as FormPublic, type FormSubmission$1 as FormSubmission, FormSubmissionsResource, FormsResource, type Fulfillment$1 as Fulfillment, type FulfillmentOrder$2 as FulfillmentOrder, FulfillmentOrdersResource, FulfillmentsResource, type GenerateVariantsResult$1 as GenerateVariantsResult, type GeoCity, type GeoCountry, type GeoCountrySummary, type GeoOutcode, type GeoPostcode, type GeoRegion, GeoResource, 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 ListDirectoryListingsParams, type ListGeoCitiesParams, type ListGeoOutcodesParams, type ListGeoRegionsParams, 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 ReorderDirectoryCategoriesBody, type ReorderDirectoryTiersBody, 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 UpdateDirectoryCategoryBody, type UpdateDirectoryListingBody, type UpdateDirectorySettingsBody, type UpdateDirectoryTierBody, 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
|
@@ -2148,6 +2148,56 @@ var DirectoryTiersResource = class {
|
|
|
2148
2148
|
}
|
|
2149
2149
|
};
|
|
2150
2150
|
|
|
2151
|
+
// src/resources/geo.ts
|
|
2152
|
+
var GeoResource = class {
|
|
2153
|
+
constructor(client) {
|
|
2154
|
+
this.client = client;
|
|
2155
|
+
}
|
|
2156
|
+
client;
|
|
2157
|
+
/** List all supported countries with region counts. */
|
|
2158
|
+
async countries() {
|
|
2159
|
+
return this.client.request("GET", "/v1/geo/countries");
|
|
2160
|
+
}
|
|
2161
|
+
/** Get a single country by ISO 3166-1 alpha-2 code. */
|
|
2162
|
+
async country(code) {
|
|
2163
|
+
return this.client.request("GET", `/v1/geo/countries/${code}`);
|
|
2164
|
+
}
|
|
2165
|
+
/** List regions, optionally filtered by country, parent subdivision, or type. */
|
|
2166
|
+
async regions(params) {
|
|
2167
|
+
return this.client.request("GET", "/v1/geo/regions", {
|
|
2168
|
+
params
|
|
2169
|
+
});
|
|
2170
|
+
}
|
|
2171
|
+
/** Get a single region by slug. */
|
|
2172
|
+
async region(slug) {
|
|
2173
|
+
return this.client.request("GET", `/v1/geo/regions/${slug}`);
|
|
2174
|
+
}
|
|
2175
|
+
/** List postcode outcodes (districts), filtered by area, country, or prefix. At least one filter required. */
|
|
2176
|
+
async outcodes(params) {
|
|
2177
|
+
return this.client.request("GET", "/v1/geo/outcodes", {
|
|
2178
|
+
params
|
|
2179
|
+
});
|
|
2180
|
+
}
|
|
2181
|
+
/** Get a single outcode by code (e.g. 'S40', 'LE1'). */
|
|
2182
|
+
async outcode(code) {
|
|
2183
|
+
return this.client.request("GET", `/v1/geo/outcodes/${code}`);
|
|
2184
|
+
}
|
|
2185
|
+
/** Lookup a full UK postcode (e.g. 'S40 1AB'). Returns coordinates, county, district, region. */
|
|
2186
|
+
async postcode(code) {
|
|
2187
|
+
return this.client.request("GET", `/v1/geo/postcodes/${code.replace(/\s+/g, "")}`);
|
|
2188
|
+
}
|
|
2189
|
+
/** List cities/towns, filtered by region slug, country code, or name prefix. At least one filter required. */
|
|
2190
|
+
async cities(params) {
|
|
2191
|
+
return this.client.request("GET", "/v1/geo/cities", {
|
|
2192
|
+
params
|
|
2193
|
+
});
|
|
2194
|
+
}
|
|
2195
|
+
/** Get a single city/town by slug. */
|
|
2196
|
+
async city(slug) {
|
|
2197
|
+
return this.client.request("GET", `/v1/geo/cities/${slug}`);
|
|
2198
|
+
}
|
|
2199
|
+
};
|
|
2200
|
+
|
|
2151
2201
|
// src/client.ts
|
|
2152
2202
|
var SDK_VERSION = "0.1.0";
|
|
2153
2203
|
var INITIAL_RETRY_DELAY = 0.5;
|
|
@@ -2257,6 +2307,8 @@ var Hydra = class {
|
|
|
2257
2307
|
directory = new DirectoryResource(this);
|
|
2258
2308
|
directoryCategories = new DirectoryCategoriesResource(this);
|
|
2259
2309
|
directoryTiers = new DirectoryTiersResource(this);
|
|
2310
|
+
// P15: Geo Reference Data
|
|
2311
|
+
geo = new GeoResource(this);
|
|
2260
2312
|
constructor(config) {
|
|
2261
2313
|
for (const key of Object.keys(config)) {
|
|
2262
2314
|
if (!VALID_CONFIG_KEYS.has(key)) {
|
|
@@ -2496,6 +2548,7 @@ export {
|
|
|
2496
2548
|
FormsResource,
|
|
2497
2549
|
FulfillmentOrdersResource,
|
|
2498
2550
|
FulfillmentsResource,
|
|
2551
|
+
GeoResource,
|
|
2499
2552
|
GiftCardsResource,
|
|
2500
2553
|
Hydra,
|
|
2501
2554
|
HydraAuthenticationError,
|