arky-sdk 0.7.78 → 0.7.84

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 CHANGED
@@ -1,13 +1,15 @@
1
+ import * as nanostores from 'nanostores';
2
+ import { atom, computed } from 'nanostores';
1
3
  import { RequestOptions, MagicLinkVerifyParams, MagicLinkRequestParams, UpdateAccountProfileParams, DeleteAccountParams, GetMeParams, SearchAccountsParams, Location, CreateLocationParams, UpdateLocationParams, DeleteLocationParams, Market, CreateMarketParams, UpdateMarketParams, DeleteMarketParams, CreateBusinessParams, UpdateBusinessParams, DeleteBusinessParams, GetBusinessParams, GetBusinessesParams, GetSubscriptionPlansParams, SubscribeParams, CreatePortalSessionParams, InviteUserParams, RemoveMemberParams, HandleInvitationParams, TestWebhookParams, GetBusinessMediaParams2, OAuthConnectParams, OAuthDisconnectParams, ListIntegrationsParams, CreateIntegrationParams, UpdateIntegrationParams, DeleteIntegrationParams, ListWebhooksParams, CreateWebhookParams, UpdateWebhookParams, DeleteWebhookParams, GetMediaParams, UploadBusinessMediaParams, DeleteBusinessMediaParams, GetBusinessMediaParams, UpdateMediaParams, TrackEmailOpenParams, TriggerNotificationParams, CreatePromoCodeParams, UpdatePromoCodeParams, DeletePromoCodeParams, GetPromoCodeParams, GetPromoCodesParams, GetShippingRatesParams, ShippingRate, ShipParams, ShipResult, CreateNodeParams, UpdateNodeParams, DeleteNodeParams, GetNodeParams, GetNodesParams, GetNodeChildrenParams, CreateFormParams, UpdateFormParams, DeleteFormParams, GetFormParams, GetFormsParams, SubmitFormParams, GetFormSubmissionsParams, GetFormSubmissionParams, UpdateFormSubmissionParams, CreateTaxonomyParams, UpdateTaxonomyParams, DeleteTaxonomyParams, GetTaxonomyParams, GetTaxonomiesParams, GetTaxonomyChildrenParams, CreateEmailTemplateParams, UpdateEmailTemplateParams, DeleteEmailTemplateParams, GetEmailTemplateParams, GetEmailTemplatesParams, CreateProductParams, UpdateProductParams, DeleteProductParams, GetProductParams, GetProductsParams, CreateOrderParams, UpdateOrderParams, GetOrderParams, GetOrdersParams, GetQuoteParams, ProcessOrderRefundParams, Slot, CreateBookingParams, UpdateBookingParams, GetBookingParams, SearchBookingsParams, GetBookingQuoteParams, ProcessBookingRefundParams, GetAvailabilityParams, AvailabilityResponse, CancelBookingItemParams, CreateServiceParams, UpdateServiceParams, DeleteServiceParams, GetServiceParams, GetServicesParams, FindServiceProvidersParams, CreateServiceProviderParams, UpdateServiceProviderParams, DeleteServiceProviderParams, CreateProviderParams, UpdateProviderParams, DeleteProviderParams, GetProviderParams, GetProvidersParams, CreateCustomerParams, Customer, GetCustomerParams, FindCustomersParams, UpdateCustomerParams, MergeCustomersParams, CreateAudienceParams, UpdateAudienceParams, GetAudienceParams, GetAudiencesParams, GetAudienceSubscribersParams, AddAudienceSubscriberParams, RemoveAudienceSubscriberParams, CreateAgentParams, UpdateAgentParams, DeleteAgentParams, GetAgentParams, GetAgentsParams, RunAgentParams, GetAgentChatsParams, GetAgentChatParams, UpdateAgentChatParams, RateAgentChatParams, GetBusinessChatsParams, CreateWorkflowParams, UpdateWorkflowParams, DeleteWorkflowParams, GetWorkflowParams, GetWorkflowsParams, TriggerWorkflowParams, GetWorkflowExecutionsParams, GetWorkflowExecutionParams } from './types.js';
2
4
  export { Access, Address, AgentChatStatus, AgentStatus, ApiResponse, Audience, AudienceAccessResponse, AudienceStatus, AudienceSubscribeResponse, AudienceSubscriber, AudienceSubscription, AudienceSubscriptionPayment, AudienceSubscriptionProvider, AudienceSubscriptionSource, AudienceSubscriptionStatus, AvailabilitySlot, Block, BookingCartItem, BookingPayment, BookingPaymentPromoCode, BookingPaymentProvider, BookingPaymentRefund, BookingPaymentTax, BookingPaymentTaxLine, BookingProviderStatus, BookingQuote, BookingServiceStatus, BookingStoreState, Business, BusinessSubscription, BusinessSubscriptionPayment, BusinessSubscriptionProvider, BusinessSubscriptionSource, BusinessSubscriptionStatus, CustomerStatus, CustomsDeclaration, CustomsItem, DaySlots, EmailTemplateStatus, EshopCartItem, EshopStoreState, Event, EventAction, ExecutionStatus, FormStatus, GeoLocation, GeoLocationBlock, Integration, IntegrationProvider, Language, Media, MediaResolution, Node, NodeResult, NodeStatus, OrderPayment, OrderPaymentPromoCode, OrderPaymentProvider, OrderPaymentRefund, OrderPaymentTax, OrderPaymentTaxLine, OrderQuote, OrderShipping, PaginatedResponse, Parcel, PaymentMethod, PaymentMethodType, Price, ProductStatus, PromoCodeStatus, PromoCodeValidation, ProviderAvailability, ProviderWithTimeline, PurchaseLabelResult, Shipment, ShipmentLine, ShippingAddress, ShippingMethod, ShippingStatus, ShippingWeightTier, SystemTemplateKey, TaxonomyStatus, Webhook, WebhookEventSubscription, Workflow, WorkflowEdge, WorkflowExecution, WorkflowHttpMethod, WorkflowHttpNode, WorkflowNode, WorkflowStatus, WorkflowSwitchNode, WorkflowTransformNode, WorkflowTriggerNode, Zone, ZoneLocation } from './types.js';
3
5
  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-DTg5d847.js';
4
6
 
5
7
  interface Activity$1 {
6
- businessId: string;
7
- customerId: string;
8
+ business_id: string;
9
+ customer_id: string;
8
10
  type: string;
9
11
  payload: Record<string, any>;
10
- createdAt: number;
12
+ created_at: number;
11
13
  }
12
14
  interface TrackParams {
13
15
  type: string;
@@ -17,10 +19,10 @@ declare const COMMON_ACTIVITY_TYPES: readonly ["page_view", "product_view", "ser
17
19
  type CommonActivityType = (typeof COMMON_ACTIVITY_TYPES)[number];
18
20
 
19
21
  interface AuthTokens {
20
- accessToken: string;
21
- refreshToken?: string;
22
- accessExpiresAt?: number;
23
- accountId?: string;
22
+ access_token: string;
23
+ refresh_token?: string;
24
+ access_expires_at?: number;
25
+ account_id?: string;
24
26
  }
25
27
  interface HttpClientConfig {
26
28
  baseUrl: string;
@@ -34,65 +36,83 @@ interface HttpClientConfig {
34
36
  isAuthenticated?: () => boolean;
35
37
  }
36
38
 
37
- interface AnalyticsSummary {
38
- orders: number;
39
- ordersChange: number;
40
- bookings: number;
41
- bookingsChange: number;
42
- newCustomers: number;
43
- newCustomersChange: number;
44
- formSubmissions: number;
45
- formSubmissionsChange: number;
39
+ type EntityKind = "product" | "service" | "provider" | "node" | "customer" | "audience" | "agent" | "workflow" | "promo_code" | "email_template" | "form" | "taxonomy" | "media" | "order" | "booking";
40
+ type Granularity = "hour" | "day" | "week" | "month" | {
41
+ minutes: 5 | 10 | 15 | 30;
42
+ };
43
+ type Measure = "count" | "uniq_customers" | "orders_created" | "bookings_created" | "new_customers" | "form_submissions" | {
44
+ entity_state: {
45
+ entity: EntityKind;
46
+ status: string;
47
+ };
48
+ };
49
+ type Dimension = "country_code" | "city" | "device_type" | "browser" | "os" | "language" | "activity_type" | "entity" | "entity_status" | {
50
+ time_bucket: {
51
+ granularity: Granularity;
52
+ };
53
+ };
54
+ type FilterField = "type" | "country_code" | "device_type" | "browser" | "os" | "language" | "entity" | "action" | "customer_id";
55
+ type FilterOp = "eq" | "neq" | "in" | "not_in" | "contains";
56
+ interface Filter {
57
+ field: FilterField;
58
+ op: FilterOp;
59
+ values: string[];
60
+ }
61
+ type TimeUnit = "hour" | "day" | "week" | "month";
62
+ type TimeRange = {
63
+ from: number;
64
+ unit: TimeUnit;
65
+ to?: number;
66
+ } | {
67
+ from: number;
68
+ to: number;
69
+ };
70
+ interface OrderBy {
71
+ field: string;
72
+ dir: "asc" | "desc";
73
+ }
74
+ interface AnalyticsQuery {
75
+ measures: Measure[];
76
+ dimensions?: Dimension[];
77
+ filters?: Filter[];
78
+ time_range: TimeRange;
79
+ granularity?: Granularity;
80
+ order_by?: OrderBy[];
81
+ limit?: number;
82
+ }
83
+ interface AnalyticsRow {
84
+ [key: string]: string | number | null;
46
85
  }
47
- interface StatusBreakdown {
48
- status: string;
49
- count: number;
86
+ interface AnalyticsQueryResponse {
87
+ rows: AnalyticsRow[];
88
+ meta: {
89
+ row_count: number;
90
+ execution_ms: number;
91
+ };
50
92
  }
51
93
 
52
94
  interface Activity {
53
- businessId: string;
54
- customerId: string;
95
+ business_id: string;
96
+ customer_id: string;
55
97
  type: string;
56
98
  payload: Record<string, any>;
57
- createdAt: number;
58
- countryCode?: string | null;
99
+ created_at: number;
100
+ country_code?: string | null;
59
101
  city?: string | null;
60
102
  region?: string | null;
61
103
  timezone?: string | null;
62
- deviceType?: string | null;
104
+ device_type?: string | null;
63
105
  browser?: string | null;
64
106
  os?: string | null;
65
107
  language?: string | null;
66
- sessionIdx?: number | null;
108
+ session_idx?: number | null;
67
109
  }
68
110
  interface TimelineParams {
69
- customerId: string;
111
+ customer_id: string;
70
112
  businessId?: string;
71
113
  limit?: number;
72
114
  cursor?: string;
73
115
  }
74
- interface CountParams {
75
- businessId?: string;
76
- type?: string;
77
- payloadKey?: string;
78
- payloadValue?: string;
79
- windowSeconds?: number;
80
- }
81
- interface ActivityTypeInfo {
82
- type: string;
83
- eventCount: number;
84
- firstSeenAt: number;
85
- lastSeenAt: number;
86
- }
87
- interface CountryBreakdownItem {
88
- countryCode: string;
89
- eventCount: number;
90
- distinctCustomers: number;
91
- }
92
- interface CountryBreakdownParams {
93
- businessId?: string;
94
- windowSeconds?: number;
95
- }
96
116
 
97
117
  interface LocationState {
98
118
  code: string;
@@ -108,6 +128,20 @@ interface GetCountriesResponse {
108
128
  cursor: string | null;
109
129
  }
110
130
 
131
+ interface StorefrontStores {
132
+ business: ReturnType<typeof atom<any>>;
133
+ market: ReturnType<typeof atom<any>>;
134
+ loading: ReturnType<typeof atom<boolean>>;
135
+ error: ReturnType<typeof atom<string | null>>;
136
+ initialized: ReturnType<typeof atom<boolean>>;
137
+ currency: ReturnType<typeof computed>;
138
+ currencySymbol: ReturnType<typeof computed>;
139
+ paymentMethods: ReturnType<typeof computed>;
140
+ paymentMethodObjects: ReturnType<typeof computed>;
141
+ paymentConfig: ReturnType<typeof computed>;
142
+ zones: ReturnType<typeof computed>;
143
+ }
144
+
111
145
  declare function getBlockLabel(block: any): string;
112
146
  declare function formatBlockValue(block: any): string;
113
147
  declare function prepareBlocksForSubmission(formData: any, blockTypes?: Record<string, string>): any[];
@@ -138,15 +172,7 @@ declare function fetchSvgContent(mediaObject: any): Promise<string | null>;
138
172
  declare function getSvgContentForAstro(mediaObject: any): Promise<string>;
139
173
  declare function injectSvgIntoElement(mediaObject: any, targetElement: HTMLElement, className?: string): Promise<void>;
140
174
 
141
- declare global {
142
- interface Window {
143
- dataLayer: any[];
144
- gtag: (...args: any[]) => void;
145
- }
146
- }
147
- declare function track(eventName: string, params?: Record<string, any>): void;
148
-
149
- declare const SDK_VERSION = "0.7.74";
175
+ declare const SDK_VERSION = "0.7.84";
150
176
  declare const SUPPORTED_FRAMEWORKS: readonly ["astro", "react", "vue", "svelte", "vanilla"];
151
177
  interface ApiConfig {
152
178
  httpClient: any;
@@ -168,7 +194,7 @@ declare function createAdmin(config: HttpClientConfig & {
168
194
  }, options?: RequestOptions): Promise<any>;
169
195
  verify(params: MagicLinkVerifyParams, options?: RequestOptions): Promise<any>;
170
196
  refresh(params: {
171
- refreshToken: string;
197
+ refresh_token: string;
172
198
  }, options?: RequestOptions): Promise<any>;
173
199
  businessCode(businessId: string, params: {
174
200
  email: string;
@@ -224,7 +250,7 @@ declare function createAdmin(config: HttpClientConfig & {
224
250
  deleteIntegration(params: DeleteIntegrationParams, options?: RequestOptions): Promise<any>;
225
251
  getIntegrationConfig(params: {
226
252
  businessId: string;
227
- type: "payment" | "shipping" | "analytics";
253
+ type: "payment" | "shipping";
228
254
  }, options?: RequestOptions): Promise<any>;
229
255
  listWebhooks(params: ListWebhooksParams, options?: RequestOptions): Promise<any>;
230
256
  createWebhook(params: CreateWebhookParams, options?: RequestOptions): Promise<any>;
@@ -381,20 +407,6 @@ declare function createAdmin(config: HttpClientConfig & {
381
407
  items: Activity[];
382
408
  cursor: string | null;
383
409
  }>;
384
- count(params: CountParams, options?: RequestOptions): Promise<{
385
- total: number;
386
- distinctCustomers: number;
387
- }>;
388
- types(params?: {
389
- businessId?: string;
390
- }, options?: RequestOptions): Promise<{
391
- items: ActivityTypeInfo[];
392
- uniqueCount: number;
393
- }>;
394
- countryBreakdown(params?: CountryBreakdownParams, options?: RequestOptions): Promise<{
395
- items: CountryBreakdownItem[];
396
- unknownCount: number;
397
- }>;
398
410
  };
399
411
  };
400
412
  automation: {
@@ -426,13 +438,9 @@ declare function createAdmin(config: HttpClientConfig & {
426
438
  };
427
439
  };
428
440
  analytics: {
429
- track: typeof track;
430
- getSummary: (params?: {
431
- period?: string;
432
- }, options?: RequestOptions) => Promise<AnalyticsSummary>;
433
- getStatusBreakdown: (params: {
434
- entity: string;
435
- }, options?: RequestOptions) => Promise<StatusBreakdown[]>;
441
+ query: (spec: AnalyticsQuery, options?: RequestOptions & {
442
+ businessId?: string;
443
+ }) => Promise<AnalyticsQueryResponse>;
436
444
  };
437
445
  setBusinessId: (businessId: string) => void;
438
446
  getBusinessId: () => string;
@@ -481,7 +489,6 @@ declare function createAdmin(config: HttpClientConfig & {
481
489
  validateKey: typeof validateKey;
482
490
  toKey: typeof toKey;
483
491
  nameToKey: typeof nameToKey;
484
- track: typeof track;
485
492
  getAvailableStock: typeof getAvailableStock;
486
493
  getReservedStock: typeof getReservedStock;
487
494
  hasStock: typeof hasStock;
@@ -489,16 +496,33 @@ declare function createAdmin(config: HttpClientConfig & {
489
496
  getFirstAvailableFCId: typeof getFirstAvailableFCId;
490
497
  };
491
498
  }>;
499
+ interface StorefrontSession {
500
+ business: any;
501
+ market: any;
502
+ }
492
503
  declare function createStorefront(config: HttpClientConfig & {
493
- market: string;
504
+ market?: string;
494
505
  locale?: string;
495
- }): Promise<{
506
+ }): {
507
+ init: () => Promise<StorefrontSession>;
508
+ stores: {
509
+ business: nanostores.PreinitializedWritableAtom<any> & object;
510
+ market: nanostores.PreinitializedWritableAtom<any> & object;
511
+ loading: nanostores.PreinitializedWritableAtom<boolean> & object;
512
+ error: nanostores.PreinitializedWritableAtom<string> & object;
513
+ initialized: nanostores.PreinitializedWritableAtom<boolean> & object;
514
+ currency: nanostores.ReadableAtom<any>;
515
+ currencySymbol: nanostores.ReadableAtom<any>;
516
+ paymentMethods: nanostores.ReadableAtom<any>;
517
+ paymentMethodObjects: nanostores.ReadableAtom<any>;
518
+ paymentConfig: nanostores.ReadableAtom<{
519
+ provider: any;
520
+ enabled: boolean;
521
+ }>;
522
+ zones: nanostores.ReadableAtom<any>;
523
+ };
496
524
  business: {
497
525
  getBusiness(options?: RequestOptions): any;
498
- getIntegrationConfig(params: {
499
- businessId?: string;
500
- type: "payment" | "shipping" | "analytics";
501
- }, options?: RequestOptions): any;
502
526
  location: {
503
527
  getCountries(options?: RequestOptions): any;
504
528
  getCountry(countryCode: string, options?: RequestOptions): any;
@@ -562,9 +586,7 @@ declare function createStorefront(config: HttpClientConfig & {
562
586
  customer: {
563
587
  initialize(params?: {
564
588
  businessId?: string;
565
- }, options?: RequestOptions): any;
566
- signInAnonymously(params?: {
567
- businessId?: string;
589
+ market?: string;
568
590
  }, options?: RequestOptions): any;
569
591
  connect(params: any, options?: RequestOptions): any;
570
592
  requestCode(params: {
@@ -577,7 +599,7 @@ declare function createStorefront(config: HttpClientConfig & {
577
599
  businessId?: string;
578
600
  }, options?: RequestOptions): any;
579
601
  refreshToken(params: {
580
- refreshToken: string;
602
+ refresh_token: string;
581
603
  businessId?: string;
582
604
  }, options?: RequestOptions): any;
583
605
  getMe(options?: RequestOptions): any;
@@ -607,35 +629,32 @@ declare function createStorefront(config: HttpClientConfig & {
607
629
  sendMessage(params: {
608
630
  id: string;
609
631
  message: string;
610
- chatId?: string;
632
+ chat_id?: string;
611
633
  businessId?: string;
612
634
  }, options?: RequestOptions): any;
613
635
  getChat(params: {
614
636
  id: string;
615
- chatId: string;
637
+ chat_id: string;
616
638
  businessId?: string;
617
639
  }, options?: RequestOptions): any;
618
640
  getChatMessages(params: {
619
641
  id: string;
620
- chatId: string;
642
+ chat_id: string;
621
643
  limit?: number;
622
644
  businessId?: string;
623
645
  }, options?: RequestOptions): any;
624
646
  rateChat(params: {
625
647
  id: string;
626
- chatId: string;
648
+ chat_id: string;
627
649
  rating: number;
628
650
  comment?: string;
629
651
  businessId?: string;
630
652
  }, options?: RequestOptions): any;
631
653
  };
632
654
  };
633
- analytics: {
634
- track: typeof track;
635
- };
636
655
  setBusinessId: (businessId: string) => void;
637
656
  getBusinessId: () => string;
638
- setMarket: (market: string) => void;
657
+ setMarket: (key: string) => void;
639
658
  getMarket: () => string;
640
659
  setLocale: (locale: string) => void;
641
660
  getLocale: () => string;
@@ -680,13 +699,12 @@ declare function createStorefront(config: HttpClientConfig & {
680
699
  validateKey: typeof validateKey;
681
700
  toKey: typeof toKey;
682
701
  nameToKey: typeof nameToKey;
683
- track: typeof track;
684
702
  getAvailableStock: typeof getAvailableStock;
685
703
  getReservedStock: typeof getReservedStock;
686
704
  hasStock: typeof hasStock;
687
705
  getInventoryAt: typeof getInventoryAt;
688
706
  getFirstAvailableFCId: typeof getFirstAvailableFCId;
689
707
  };
690
- }>;
708
+ };
691
709
 
692
- export { type Activity$1 as Activity, type ActivityTypeInfo, type AnalyticsSummary, type ApiConfig, AvailabilityResponse, COMMON_ACTIVITY_TYPES, type CommonActivityType, type CountParams, CreateAgentParams, CreateLocationParams, DeleteLocationParams, GetAgentParams, GetAgentsParams, GetAvailabilityParams, type GetCountriesResponse, GetShippingRatesParams, type HttpClientConfig, Location, type LocationCountry, type LocationState, Market, SDK_VERSION, SUPPORTED_FRAMEWORKS, ShipParams, ShipResult, ShippingRate, Slot, type StatusBreakdown, type TimelineParams, type TrackParams, UpdateAgentParams, UpdateLocationParams, createAdmin, createStorefront };
710
+ export { type Activity$1 as Activity, type AnalyticsQuery, type AnalyticsQueryResponse, type AnalyticsRow, type ApiConfig, AvailabilityResponse, COMMON_ACTIVITY_TYPES, type CommonActivityType, CreateAgentParams, CreateLocationParams, DeleteLocationParams, type Dimension, type EntityKind, type Filter, type FilterField, type FilterOp, GetAgentParams, GetAgentsParams, GetAvailabilityParams, type GetCountriesResponse, GetShippingRatesParams, type Granularity, type HttpClientConfig, Location, type LocationCountry, type LocationState, Market, type Measure, type OrderBy, SDK_VERSION, SUPPORTED_FRAMEWORKS, ShipParams, ShipResult, ShippingRate, Slot, type StorefrontSession, type StorefrontStores, type TimeRange, type TimeUnit, type TimelineParams, type TrackParams, UpdateAgentParams, UpdateLocationParams, createAdmin, createStorefront };