arky-sdk 0.4.32 → 0.4.34
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-C28uWlRE.d.cts +43 -0
- package/dist/index-GZfY5CmP.d.ts +43 -0
- package/dist/index.cjs +27 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -2
- package/dist/index.d.ts +7 -2
- package/dist/index.js +27 -2
- package/dist/index.js.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +29 -16
- package/dist/types.d.ts +29 -16
- package/dist/types.js.map +1 -1
- package/dist/utils.cjs +25 -0
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +21 -1
- package/dist/utils.js.map +1 -1
- package/package.json +1 -1
- package/dist/index-BYfD8CyL.d.cts +0 -18
- package/dist/index-BmbG-NrS.d.ts +0 -18
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RequestOptions, MagicLinkVerifyParams, MagicLinkRequestParams, UpdateAccountProfileParams, DeleteAccountParams, AddPhoneNumberParams, PhoneNumberConfirmParams, GetMeParams, SearchAccountsParams, AccountSubscribeParams, CreateBusinessParams, UpdateBusinessParams, DeleteBusinessParams, GetBusinessParams, GetBusinessesParams, GetBusinessParentsParams, TriggerBuildsParams, GetSubscriptionPlansParams, GetSubscriptionParams, SubscribeParams, CreatePortalSessionParams, InviteUserParams, HandleInvitationParams, TestWebhookParams, GetBusinessMediaParams2, ProcessRefundParams, GetBusinessEventsParams, UpdateBusinessEventParams, ConnectStripeParams, DisconnectStripeParams, UploadBusinessMediaParams, DeleteBusinessMediaParams, GetBusinessMediaParams, UpdateMediaParams, TrackEmailOpenParams, GetDeliveryStatsParams, CreatePromoCodeParams, UpdatePromoCodeParams, DeletePromoCodeParams, GetPromoCodeParams, GetPromoCodesParams, CreateNodeParams, UpdateNodeParams, DeleteNodeParams, GetNodeParams, GetNodesParams, GetNodeChildrenParams, GenerateBlocksParams, GetVariableMetadataParams, CreateProductParams, UpdateProductParams, DeleteProductParams, GetProductParams, GetProductsParams, CreateOrderParams, UpdateOrderParams, GetOrderParams, GetOrdersParams, GetQuoteParams, OrderCheckoutParams, Slot, CreateReservationParams, UpdateReservationParams, ReservationCheckoutParams, GetReservationParams, SearchReservationsParams, GetReservationQuoteParams, CreateServiceParams, UpdateServiceParams, DeleteServiceParams, BulkScheduleParams, GetServiceParams, GetServicesParams, CreateProviderParams, UpdateProviderParams, DeleteProviderParams, GetProviderParams, GetProvidersParams, GetBusinessServiceWorkingTimeParams, CreateWorkflowParams, UpdateWorkflowParams, DeleteWorkflowParams, GetWorkflowParams, GetWorkflowsParams, TriggerWorkflowParams, CreateAudienceParams, UpdateAudienceParams, GetAudienceParams, GetAudiencesParams, SubscribeAudienceParams, GetAudienceSubscribersParams, RevokeAudienceSubscriptionParams } from './types.cjs';
|
|
2
2
|
export { Access, AnalyticsConfig, ApiResponse, Audience, AudienceAccessResponse, AudienceSubscribeResponse, AudienceSubscriber, Block, Business, BusinessConfig, BusinessEvent, BusinessEventAction, DayAvailability, EshopCartItem, EshopStoreState, GetAvailabilityParams, GetSlotsForDateParams, Language, Location, Market, Media, MediaResolution, Node, PaginatedResponse, Payment, PaymentMethod, PaymentMethodType, PaymentProviderConfig, PaymentRefund, Price, PromoCodeValidation, ProviderWithTimeline, Quote, ReservationCartItem, ReservationStoreState, ShippingMethod, ShippingWeightTier, SystemTemplateKey, Workflow, WorkflowEdge, WorkflowHttpMethod, WorkflowHttpNode, WorkflowIfNode, WorkflowLoopNode, WorkflowNode, WorkflowTriggerNode, WorkflowWaitNode, Zone } from './types.cjs';
|
|
3
|
-
import { f as formatPayment, a as formatMinor, g as getCurrencySymbol, b as getCurrencyName, i as isValidKey, v as validateKey, t as toKey, n as nameToKey } from './index-
|
|
3
|
+
import { f as formatPayment, a as formatMinor, g as getCurrencySymbol, b as getCurrencyName, i as isValidKey, v as validateKey, t as toKey, n as nameToKey, c as getAvailableStock, d as getReservedStock, h as hasStock, e as getInventoryAt, j as getFirstAvailableFCId } from './index-C28uWlRE.cjs';
|
|
4
4
|
|
|
5
5
|
interface AuthTokens {
|
|
6
6
|
accessToken: string;
|
|
@@ -116,7 +116,7 @@ declare global {
|
|
|
116
116
|
}
|
|
117
117
|
declare function track(eventName: string, params?: Record<string, any>): void;
|
|
118
118
|
|
|
119
|
-
declare const SDK_VERSION = "0.4.
|
|
119
|
+
declare const SDK_VERSION = "0.4.34";
|
|
120
120
|
declare const SUPPORTED_FRAMEWORKS: readonly ["astro", "react", "vue", "svelte", "vanilla"];
|
|
121
121
|
interface ApiConfig {
|
|
122
122
|
httpClient: any;
|
|
@@ -338,6 +338,11 @@ declare function createArkySDK(config: HttpClientConfig & {
|
|
|
338
338
|
toKey: typeof toKey;
|
|
339
339
|
nameToKey: typeof nameToKey;
|
|
340
340
|
track: typeof track;
|
|
341
|
+
getAvailableStock: typeof getAvailableStock;
|
|
342
|
+
getReservedStock: typeof getReservedStock;
|
|
343
|
+
hasStock: typeof hasStock;
|
|
344
|
+
getInventoryAt: typeof getInventoryAt;
|
|
345
|
+
getFirstAvailableFCId: typeof getFirstAvailableFCId;
|
|
341
346
|
};
|
|
342
347
|
getPlatformConfig: () => PlatformConfig;
|
|
343
348
|
getStripePublicKey: () => string;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RequestOptions, MagicLinkVerifyParams, MagicLinkRequestParams, UpdateAccountProfileParams, DeleteAccountParams, AddPhoneNumberParams, PhoneNumberConfirmParams, GetMeParams, SearchAccountsParams, AccountSubscribeParams, CreateBusinessParams, UpdateBusinessParams, DeleteBusinessParams, GetBusinessParams, GetBusinessesParams, GetBusinessParentsParams, TriggerBuildsParams, GetSubscriptionPlansParams, GetSubscriptionParams, SubscribeParams, CreatePortalSessionParams, InviteUserParams, HandleInvitationParams, TestWebhookParams, GetBusinessMediaParams2, ProcessRefundParams, GetBusinessEventsParams, UpdateBusinessEventParams, ConnectStripeParams, DisconnectStripeParams, UploadBusinessMediaParams, DeleteBusinessMediaParams, GetBusinessMediaParams, UpdateMediaParams, TrackEmailOpenParams, GetDeliveryStatsParams, CreatePromoCodeParams, UpdatePromoCodeParams, DeletePromoCodeParams, GetPromoCodeParams, GetPromoCodesParams, CreateNodeParams, UpdateNodeParams, DeleteNodeParams, GetNodeParams, GetNodesParams, GetNodeChildrenParams, GenerateBlocksParams, GetVariableMetadataParams, CreateProductParams, UpdateProductParams, DeleteProductParams, GetProductParams, GetProductsParams, CreateOrderParams, UpdateOrderParams, GetOrderParams, GetOrdersParams, GetQuoteParams, OrderCheckoutParams, Slot, CreateReservationParams, UpdateReservationParams, ReservationCheckoutParams, GetReservationParams, SearchReservationsParams, GetReservationQuoteParams, CreateServiceParams, UpdateServiceParams, DeleteServiceParams, BulkScheduleParams, GetServiceParams, GetServicesParams, CreateProviderParams, UpdateProviderParams, DeleteProviderParams, GetProviderParams, GetProvidersParams, GetBusinessServiceWorkingTimeParams, CreateWorkflowParams, UpdateWorkflowParams, DeleteWorkflowParams, GetWorkflowParams, GetWorkflowsParams, TriggerWorkflowParams, CreateAudienceParams, UpdateAudienceParams, GetAudienceParams, GetAudiencesParams, SubscribeAudienceParams, GetAudienceSubscribersParams, RevokeAudienceSubscriptionParams } from './types.js';
|
|
2
2
|
export { Access, AnalyticsConfig, ApiResponse, Audience, AudienceAccessResponse, AudienceSubscribeResponse, AudienceSubscriber, Block, Business, BusinessConfig, BusinessEvent, BusinessEventAction, DayAvailability, EshopCartItem, EshopStoreState, GetAvailabilityParams, GetSlotsForDateParams, Language, Location, Market, Media, MediaResolution, Node, PaginatedResponse, Payment, PaymentMethod, PaymentMethodType, PaymentProviderConfig, PaymentRefund, Price, PromoCodeValidation, ProviderWithTimeline, Quote, ReservationCartItem, ReservationStoreState, ShippingMethod, ShippingWeightTier, SystemTemplateKey, Workflow, WorkflowEdge, WorkflowHttpMethod, WorkflowHttpNode, WorkflowIfNode, WorkflowLoopNode, WorkflowNode, WorkflowTriggerNode, WorkflowWaitNode, Zone } from './types.js';
|
|
3
|
-
import { f as formatPayment, a as formatMinor, g as getCurrencySymbol, b as getCurrencyName, i as isValidKey, v as validateKey, t as toKey, n as nameToKey } from './index-
|
|
3
|
+
import { f as formatPayment, a as formatMinor, g as getCurrencySymbol, b as getCurrencyName, i as isValidKey, v as validateKey, t as toKey, n as nameToKey, c as getAvailableStock, d as getReservedStock, h as hasStock, e as getInventoryAt, j as getFirstAvailableFCId } from './index-GZfY5CmP.js';
|
|
4
4
|
|
|
5
5
|
interface AuthTokens {
|
|
6
6
|
accessToken: string;
|
|
@@ -116,7 +116,7 @@ declare global {
|
|
|
116
116
|
}
|
|
117
117
|
declare function track(eventName: string, params?: Record<string, any>): void;
|
|
118
118
|
|
|
119
|
-
declare const SDK_VERSION = "0.4.
|
|
119
|
+
declare const SDK_VERSION = "0.4.34";
|
|
120
120
|
declare const SUPPORTED_FRAMEWORKS: readonly ["astro", "react", "vue", "svelte", "vanilla"];
|
|
121
121
|
interface ApiConfig {
|
|
122
122
|
httpClient: any;
|
|
@@ -338,6 +338,11 @@ declare function createArkySDK(config: HttpClientConfig & {
|
|
|
338
338
|
toKey: typeof toKey;
|
|
339
339
|
nameToKey: typeof nameToKey;
|
|
340
340
|
track: typeof track;
|
|
341
|
+
getAvailableStock: typeof getAvailableStock;
|
|
342
|
+
getReservedStock: typeof getReservedStock;
|
|
343
|
+
hasStock: typeof hasStock;
|
|
344
|
+
getInventoryAt: typeof getInventoryAt;
|
|
345
|
+
getFirstAvailableFCId: typeof getFirstAvailableFCId;
|
|
341
346
|
};
|
|
342
347
|
getPlatformConfig: () => PlatformConfig;
|
|
343
348
|
getStripePublicKey: () => string;
|
package/dist/index.js
CHANGED
|
@@ -1621,8 +1621,28 @@ function track(eventName, params) {
|
|
|
1621
1621
|
}
|
|
1622
1622
|
}
|
|
1623
1623
|
|
|
1624
|
+
// src/utils/inventory.ts
|
|
1625
|
+
function getAvailableStock(variant) {
|
|
1626
|
+
if (!variant?.inventory) return 0;
|
|
1627
|
+
return variant.inventory.reduce((sum, inv) => sum + inv.available, 0);
|
|
1628
|
+
}
|
|
1629
|
+
function getReservedStock(variant) {
|
|
1630
|
+
if (!variant?.inventory) return 0;
|
|
1631
|
+
return variant.inventory.reduce((sum, inv) => sum + inv.reserved, 0);
|
|
1632
|
+
}
|
|
1633
|
+
function hasStock(variant, quantity = 1) {
|
|
1634
|
+
return getAvailableStock(variant) >= quantity;
|
|
1635
|
+
}
|
|
1636
|
+
function getInventoryAt(variant, fulfillmentCenterId) {
|
|
1637
|
+
return variant?.inventory?.find((inv) => inv.fulfillmentCenterId === fulfillmentCenterId);
|
|
1638
|
+
}
|
|
1639
|
+
function getFirstAvailableFCId(variant, quantity = 1) {
|
|
1640
|
+
const inv = variant?.inventory?.find((i) => i.available >= quantity);
|
|
1641
|
+
return inv?.fulfillmentCenterId;
|
|
1642
|
+
}
|
|
1643
|
+
|
|
1624
1644
|
// src/index.ts
|
|
1625
|
-
var SDK_VERSION = "0.4.
|
|
1645
|
+
var SDK_VERSION = "0.4.34";
|
|
1626
1646
|
var SUPPORTED_FRAMEWORKS = [
|
|
1627
1647
|
"astro",
|
|
1628
1648
|
"react",
|
|
@@ -1722,7 +1742,12 @@ async function createArkySDK(config) {
|
|
|
1722
1742
|
validateKey,
|
|
1723
1743
|
toKey,
|
|
1724
1744
|
nameToKey,
|
|
1725
|
-
track
|
|
1745
|
+
track,
|
|
1746
|
+
getAvailableStock,
|
|
1747
|
+
getReservedStock,
|
|
1748
|
+
hasStock,
|
|
1749
|
+
getInventoryAt,
|
|
1750
|
+
getFirstAvailableFCId
|
|
1726
1751
|
},
|
|
1727
1752
|
// Platform config helpers
|
|
1728
1753
|
getPlatformConfig: () => platformApi.getConfigCache(),
|