arky-sdk 0.7.65 → 0.7.67
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.cjs +114 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +60 -5
- package/dist/index.d.ts +60 -5
- package/dist/index.js +114 -20
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -12,14 +12,52 @@ interface HttpClientConfig {
|
|
|
12
12
|
baseUrl: string;
|
|
13
13
|
businessId: string;
|
|
14
14
|
refreshPath?: string;
|
|
15
|
-
getToken
|
|
16
|
-
setToken
|
|
17
|
-
logout
|
|
15
|
+
getToken?: () => Promise<AuthTokens> | AuthTokens;
|
|
16
|
+
setToken?: (tokens: AuthTokens) => void;
|
|
17
|
+
logout?: () => void;
|
|
18
18
|
navigate?: (path: string) => void;
|
|
19
19
|
loginFallbackPath?: string;
|
|
20
20
|
isAuthenticated?: () => boolean;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
interface AnalyticsSummary {
|
|
24
|
+
revenue: number;
|
|
25
|
+
revenueChange: number;
|
|
26
|
+
orders: number;
|
|
27
|
+
ordersChange: number;
|
|
28
|
+
bookings: number;
|
|
29
|
+
bookingsChange: number;
|
|
30
|
+
newCustomers: number;
|
|
31
|
+
newCustomersChange: number;
|
|
32
|
+
formSubmissions: number;
|
|
33
|
+
formSubmissionsChange: number;
|
|
34
|
+
activeProducts: number;
|
|
35
|
+
activeServices: number;
|
|
36
|
+
activeProviders: number;
|
|
37
|
+
}
|
|
38
|
+
interface TimeSeriesPoint {
|
|
39
|
+
date: string;
|
|
40
|
+
value: number;
|
|
41
|
+
}
|
|
42
|
+
interface TimeSeriesResponse {
|
|
43
|
+
period: {
|
|
44
|
+
start: string;
|
|
45
|
+
end: string;
|
|
46
|
+
};
|
|
47
|
+
interval: string;
|
|
48
|
+
series: Record<string, TimeSeriesPoint[]>;
|
|
49
|
+
}
|
|
50
|
+
interface TopEntity {
|
|
51
|
+
entityId: string;
|
|
52
|
+
label: string;
|
|
53
|
+
count: number;
|
|
54
|
+
revenue: number;
|
|
55
|
+
}
|
|
56
|
+
interface StatusBreakdown {
|
|
57
|
+
status: string;
|
|
58
|
+
count: number;
|
|
59
|
+
}
|
|
60
|
+
|
|
23
61
|
type ReactionTargetType = "product" | "service" | "provider" | "booking" | "node";
|
|
24
62
|
type ReactionStatus = "pending" | "published" | "hidden" | "removed";
|
|
25
63
|
interface ReactionTarget {
|
|
@@ -148,7 +186,7 @@ declare global {
|
|
|
148
186
|
}
|
|
149
187
|
declare function track(eventName: string, params?: Record<string, any>): void;
|
|
150
188
|
|
|
151
|
-
declare const SDK_VERSION = "0.7.
|
|
189
|
+
declare const SDK_VERSION = "0.7.67";
|
|
152
190
|
declare const SUPPORTED_FRAMEWORKS: readonly ["astro", "react", "vue", "svelte", "vanilla"];
|
|
153
191
|
interface ApiConfig {
|
|
154
192
|
httpClient: any;
|
|
@@ -426,6 +464,23 @@ declare function createAdmin(config: HttpClientConfig & {
|
|
|
426
464
|
};
|
|
427
465
|
analytics: {
|
|
428
466
|
track: typeof track;
|
|
467
|
+
getSummary: (params?: {
|
|
468
|
+
period?: string;
|
|
469
|
+
}, options?: RequestOptions) => Promise<AnalyticsSummary>;
|
|
470
|
+
getSeries: (params: {
|
|
471
|
+
metrics: string[];
|
|
472
|
+
period?: string;
|
|
473
|
+
interval?: string;
|
|
474
|
+
}, options?: RequestOptions) => Promise<TimeSeriesResponse>;
|
|
475
|
+
getTopEntities: (params: {
|
|
476
|
+
entity: string;
|
|
477
|
+
period?: string;
|
|
478
|
+
limit?: number;
|
|
479
|
+
}, options?: RequestOptions) => Promise<TopEntity[]>;
|
|
480
|
+
getStatusBreakdown: (params: {
|
|
481
|
+
entity: string;
|
|
482
|
+
period?: string;
|
|
483
|
+
}, options?: RequestOptions) => Promise<StatusBreakdown[]>;
|
|
429
484
|
};
|
|
430
485
|
setBusinessId: (businessId: string) => void;
|
|
431
486
|
getBusinessId: () => string;
|
|
@@ -692,4 +747,4 @@ declare function createStorefront(config: HttpClientConfig & {
|
|
|
692
747
|
};
|
|
693
748
|
}>;
|
|
694
749
|
|
|
695
|
-
export { type ApiConfig, AvailabilityResponse, Block, CreateAgentParams, CreateLocationParams, type CreateReactionParams, DEFAULT_REACTION_KINDS, DeleteLocationParams, type EngagementSummary, type EngagementSummaryParams, type FindReactionsParams, GetAgentParams, GetAgentsParams, GetAvailabilityParams, type GetCountriesResponse, type GetReactionParams, GetShippingRatesParams, type HttpClientConfig, Location, type LocationCountry, type LocationState, Market, type ModerateReactionParams, REACTION_KIND_REGEX, type Reaction, type ReactionStatus, type ReactionTarget, type ReactionTargetType, SDK_VERSION, SUPPORTED_FRAMEWORKS, ShipParams, ShipResult, ShippingRate, Slot, UpdateAgentParams, UpdateLocationParams, type UpdateReactionParams, computeAverageStars, createAdmin, createStorefront, isValidReactionKind };
|
|
750
|
+
export { type AnalyticsSummary, type ApiConfig, AvailabilityResponse, Block, CreateAgentParams, CreateLocationParams, type CreateReactionParams, DEFAULT_REACTION_KINDS, DeleteLocationParams, type EngagementSummary, type EngagementSummaryParams, type FindReactionsParams, GetAgentParams, GetAgentsParams, GetAvailabilityParams, type GetCountriesResponse, type GetReactionParams, GetShippingRatesParams, type HttpClientConfig, Location, type LocationCountry, type LocationState, Market, type ModerateReactionParams, REACTION_KIND_REGEX, type Reaction, type ReactionStatus, type ReactionTarget, type ReactionTargetType, SDK_VERSION, SUPPORTED_FRAMEWORKS, ShipParams, ShipResult, ShippingRate, Slot, type StatusBreakdown, type TimeSeriesPoint, type TimeSeriesResponse, type TopEntity, UpdateAgentParams, UpdateLocationParams, type UpdateReactionParams, computeAverageStars, createAdmin, createStorefront, isValidReactionKind };
|
package/dist/index.d.ts
CHANGED
|
@@ -12,14 +12,52 @@ interface HttpClientConfig {
|
|
|
12
12
|
baseUrl: string;
|
|
13
13
|
businessId: string;
|
|
14
14
|
refreshPath?: string;
|
|
15
|
-
getToken
|
|
16
|
-
setToken
|
|
17
|
-
logout
|
|
15
|
+
getToken?: () => Promise<AuthTokens> | AuthTokens;
|
|
16
|
+
setToken?: (tokens: AuthTokens) => void;
|
|
17
|
+
logout?: () => void;
|
|
18
18
|
navigate?: (path: string) => void;
|
|
19
19
|
loginFallbackPath?: string;
|
|
20
20
|
isAuthenticated?: () => boolean;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
interface AnalyticsSummary {
|
|
24
|
+
revenue: number;
|
|
25
|
+
revenueChange: number;
|
|
26
|
+
orders: number;
|
|
27
|
+
ordersChange: number;
|
|
28
|
+
bookings: number;
|
|
29
|
+
bookingsChange: number;
|
|
30
|
+
newCustomers: number;
|
|
31
|
+
newCustomersChange: number;
|
|
32
|
+
formSubmissions: number;
|
|
33
|
+
formSubmissionsChange: number;
|
|
34
|
+
activeProducts: number;
|
|
35
|
+
activeServices: number;
|
|
36
|
+
activeProviders: number;
|
|
37
|
+
}
|
|
38
|
+
interface TimeSeriesPoint {
|
|
39
|
+
date: string;
|
|
40
|
+
value: number;
|
|
41
|
+
}
|
|
42
|
+
interface TimeSeriesResponse {
|
|
43
|
+
period: {
|
|
44
|
+
start: string;
|
|
45
|
+
end: string;
|
|
46
|
+
};
|
|
47
|
+
interval: string;
|
|
48
|
+
series: Record<string, TimeSeriesPoint[]>;
|
|
49
|
+
}
|
|
50
|
+
interface TopEntity {
|
|
51
|
+
entityId: string;
|
|
52
|
+
label: string;
|
|
53
|
+
count: number;
|
|
54
|
+
revenue: number;
|
|
55
|
+
}
|
|
56
|
+
interface StatusBreakdown {
|
|
57
|
+
status: string;
|
|
58
|
+
count: number;
|
|
59
|
+
}
|
|
60
|
+
|
|
23
61
|
type ReactionTargetType = "product" | "service" | "provider" | "booking" | "node";
|
|
24
62
|
type ReactionStatus = "pending" | "published" | "hidden" | "removed";
|
|
25
63
|
interface ReactionTarget {
|
|
@@ -148,7 +186,7 @@ declare global {
|
|
|
148
186
|
}
|
|
149
187
|
declare function track(eventName: string, params?: Record<string, any>): void;
|
|
150
188
|
|
|
151
|
-
declare const SDK_VERSION = "0.7.
|
|
189
|
+
declare const SDK_VERSION = "0.7.67";
|
|
152
190
|
declare const SUPPORTED_FRAMEWORKS: readonly ["astro", "react", "vue", "svelte", "vanilla"];
|
|
153
191
|
interface ApiConfig {
|
|
154
192
|
httpClient: any;
|
|
@@ -426,6 +464,23 @@ declare function createAdmin(config: HttpClientConfig & {
|
|
|
426
464
|
};
|
|
427
465
|
analytics: {
|
|
428
466
|
track: typeof track;
|
|
467
|
+
getSummary: (params?: {
|
|
468
|
+
period?: string;
|
|
469
|
+
}, options?: RequestOptions) => Promise<AnalyticsSummary>;
|
|
470
|
+
getSeries: (params: {
|
|
471
|
+
metrics: string[];
|
|
472
|
+
period?: string;
|
|
473
|
+
interval?: string;
|
|
474
|
+
}, options?: RequestOptions) => Promise<TimeSeriesResponse>;
|
|
475
|
+
getTopEntities: (params: {
|
|
476
|
+
entity: string;
|
|
477
|
+
period?: string;
|
|
478
|
+
limit?: number;
|
|
479
|
+
}, options?: RequestOptions) => Promise<TopEntity[]>;
|
|
480
|
+
getStatusBreakdown: (params: {
|
|
481
|
+
entity: string;
|
|
482
|
+
period?: string;
|
|
483
|
+
}, options?: RequestOptions) => Promise<StatusBreakdown[]>;
|
|
429
484
|
};
|
|
430
485
|
setBusinessId: (businessId: string) => void;
|
|
431
486
|
getBusinessId: () => string;
|
|
@@ -692,4 +747,4 @@ declare function createStorefront(config: HttpClientConfig & {
|
|
|
692
747
|
};
|
|
693
748
|
}>;
|
|
694
749
|
|
|
695
|
-
export { type ApiConfig, AvailabilityResponse, Block, CreateAgentParams, CreateLocationParams, type CreateReactionParams, DEFAULT_REACTION_KINDS, DeleteLocationParams, type EngagementSummary, type EngagementSummaryParams, type FindReactionsParams, GetAgentParams, GetAgentsParams, GetAvailabilityParams, type GetCountriesResponse, type GetReactionParams, GetShippingRatesParams, type HttpClientConfig, Location, type LocationCountry, type LocationState, Market, type ModerateReactionParams, REACTION_KIND_REGEX, type Reaction, type ReactionStatus, type ReactionTarget, type ReactionTargetType, SDK_VERSION, SUPPORTED_FRAMEWORKS, ShipParams, ShipResult, ShippingRate, Slot, UpdateAgentParams, UpdateLocationParams, type UpdateReactionParams, computeAverageStars, createAdmin, createStorefront, isValidReactionKind };
|
|
750
|
+
export { type AnalyticsSummary, type ApiConfig, AvailabilityResponse, Block, CreateAgentParams, CreateLocationParams, type CreateReactionParams, DEFAULT_REACTION_KINDS, DeleteLocationParams, type EngagementSummary, type EngagementSummaryParams, type FindReactionsParams, GetAgentParams, GetAgentsParams, GetAvailabilityParams, type GetCountriesResponse, type GetReactionParams, GetShippingRatesParams, type HttpClientConfig, Location, type LocationCountry, type LocationState, Market, type ModerateReactionParams, REACTION_KIND_REGEX, type Reaction, type ReactionStatus, type ReactionTarget, type ReactionTargetType, SDK_VERSION, SUPPORTED_FRAMEWORKS, ShipParams, ShipResult, ShippingRate, Slot, type StatusBreakdown, type TimeSeriesPoint, type TimeSeriesResponse, type TopEntity, UpdateAgentParams, UpdateLocationParams, type UpdateReactionParams, computeAverageStars, createAdmin, createStorefront, isValidReactionKind };
|
package/dist/index.js
CHANGED
|
@@ -43,7 +43,42 @@ function buildQueryString(params) {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
// src/services/createHttpClient.ts
|
|
46
|
+
var STORAGE_KEYS = {
|
|
47
|
+
accessToken: "arky_token",
|
|
48
|
+
refreshToken: "arky_refresh",
|
|
49
|
+
accessExpiresAt: "arky_expires_at"
|
|
50
|
+
};
|
|
51
|
+
function defaultGetToken() {
|
|
52
|
+
if (typeof window === "undefined") return { accessToken: "" };
|
|
53
|
+
return {
|
|
54
|
+
accessToken: localStorage.getItem(STORAGE_KEYS.accessToken) || "",
|
|
55
|
+
refreshToken: localStorage.getItem(STORAGE_KEYS.refreshToken) || "",
|
|
56
|
+
accessExpiresAt: parseInt(localStorage.getItem(STORAGE_KEYS.accessExpiresAt) || "0", 10)
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function defaultSetToken(tokens) {
|
|
60
|
+
if (typeof window === "undefined") return;
|
|
61
|
+
if (tokens.accessToken) {
|
|
62
|
+
localStorage.setItem(STORAGE_KEYS.accessToken, tokens.accessToken);
|
|
63
|
+
localStorage.setItem(STORAGE_KEYS.refreshToken, tokens.refreshToken || "");
|
|
64
|
+
localStorage.setItem(STORAGE_KEYS.accessExpiresAt, (tokens.accessExpiresAt || 0).toString());
|
|
65
|
+
} else {
|
|
66
|
+
Object.values(STORAGE_KEYS).forEach((key) => localStorage.removeItem(key));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function defaultLogout() {
|
|
70
|
+
if (typeof window === "undefined") return;
|
|
71
|
+
Object.values(STORAGE_KEYS).forEach((key) => localStorage.removeItem(key));
|
|
72
|
+
}
|
|
73
|
+
function defaultIsAuthenticated() {
|
|
74
|
+
if (typeof window === "undefined") return false;
|
|
75
|
+
const token = localStorage.getItem(STORAGE_KEYS.accessToken) || "";
|
|
76
|
+
return token.startsWith("customer_") || token.startsWith("account_");
|
|
77
|
+
}
|
|
46
78
|
function createHttpClient(cfg) {
|
|
79
|
+
const getToken = cfg.getToken || defaultGetToken;
|
|
80
|
+
const setToken = cfg.setToken || defaultSetToken;
|
|
81
|
+
const logout = cfg.logout || defaultLogout;
|
|
47
82
|
const refreshEndpoint = `${cfg.baseUrl}${cfg.refreshPath || "/v1/auth/refresh"}`;
|
|
48
83
|
let refreshPromise = null;
|
|
49
84
|
async function ensureFreshToken() {
|
|
@@ -51,9 +86,9 @@ function createHttpClient(cfg) {
|
|
|
51
86
|
return refreshPromise;
|
|
52
87
|
}
|
|
53
88
|
refreshPromise = (async () => {
|
|
54
|
-
const { refreshToken } = await
|
|
89
|
+
const { refreshToken } = await getToken();
|
|
55
90
|
if (!refreshToken) {
|
|
56
|
-
|
|
91
|
+
logout();
|
|
57
92
|
const err = new Error("No refresh token available");
|
|
58
93
|
err.name = "ApiError";
|
|
59
94
|
err.statusCode = 401;
|
|
@@ -65,14 +100,14 @@ function createHttpClient(cfg) {
|
|
|
65
100
|
body: JSON.stringify({ refreshToken })
|
|
66
101
|
});
|
|
67
102
|
if (!refRes.ok) {
|
|
68
|
-
|
|
103
|
+
logout();
|
|
69
104
|
const err = new Error("Token refresh failed");
|
|
70
105
|
err.name = "ApiError";
|
|
71
106
|
err.statusCode = 401;
|
|
72
107
|
throw err;
|
|
73
108
|
}
|
|
74
109
|
const data = await refRes.json();
|
|
75
|
-
|
|
110
|
+
setToken(data);
|
|
76
111
|
})().finally(() => {
|
|
77
112
|
refreshPromise = null;
|
|
78
113
|
});
|
|
@@ -87,11 +122,11 @@ function createHttpClient(cfg) {
|
|
|
87
122
|
"Content-Type": "application/json",
|
|
88
123
|
...options?.headers || {}
|
|
89
124
|
};
|
|
90
|
-
let { accessToken, accessExpiresAt } = await
|
|
125
|
+
let { accessToken, accessExpiresAt } = await getToken();
|
|
91
126
|
const nowSec = Date.now() / 1e3;
|
|
92
127
|
if (accessExpiresAt && nowSec > accessExpiresAt) {
|
|
93
128
|
await ensureFreshToken();
|
|
94
|
-
const tokens = await
|
|
129
|
+
const tokens = await getToken();
|
|
95
130
|
accessToken = tokens.accessToken;
|
|
96
131
|
}
|
|
97
132
|
if (accessToken) {
|
|
@@ -124,7 +159,7 @@ function createHttpClient(cfg) {
|
|
|
124
159
|
if (res.status === 401 && !options?.["_retried"]) {
|
|
125
160
|
try {
|
|
126
161
|
await ensureFreshToken();
|
|
127
|
-
const tokens = await
|
|
162
|
+
const tokens = await getToken();
|
|
128
163
|
headers["Authorization"] = `Bearer ${tokens.accessToken}`;
|
|
129
164
|
fetchOpts.headers = headers;
|
|
130
165
|
return request(method, path, body, { ...options, _retried: true });
|
|
@@ -1866,6 +1901,49 @@ var createTaxonomyApi = (apiConfig) => {
|
|
|
1866
1901
|
};
|
|
1867
1902
|
};
|
|
1868
1903
|
|
|
1904
|
+
// src/api/analytics.ts
|
|
1905
|
+
var createAnalyticsApi = (apiConfig) => {
|
|
1906
|
+
return {
|
|
1907
|
+
async getSummary(params, options) {
|
|
1908
|
+
return apiConfig.httpClient.get(
|
|
1909
|
+
`/v1/businesses/${apiConfig.businessId}/analytics/summary`,
|
|
1910
|
+
{
|
|
1911
|
+
...options,
|
|
1912
|
+
params: params || {}
|
|
1913
|
+
}
|
|
1914
|
+
);
|
|
1915
|
+
},
|
|
1916
|
+
async getSeries(params, options) {
|
|
1917
|
+
const { metrics, ...rest } = params;
|
|
1918
|
+
return apiConfig.httpClient.get(
|
|
1919
|
+
`/v1/businesses/${apiConfig.businessId}/analytics/series`,
|
|
1920
|
+
{
|
|
1921
|
+
...options,
|
|
1922
|
+
params: { ...rest, metrics: metrics.join(",") }
|
|
1923
|
+
}
|
|
1924
|
+
);
|
|
1925
|
+
},
|
|
1926
|
+
async getTopEntities(params, options) {
|
|
1927
|
+
return apiConfig.httpClient.get(
|
|
1928
|
+
`/v1/businesses/${apiConfig.businessId}/analytics/top`,
|
|
1929
|
+
{
|
|
1930
|
+
...options,
|
|
1931
|
+
params
|
|
1932
|
+
}
|
|
1933
|
+
);
|
|
1934
|
+
},
|
|
1935
|
+
async getStatusBreakdown(params, options) {
|
|
1936
|
+
return apiConfig.httpClient.get(
|
|
1937
|
+
`/v1/businesses/${apiConfig.businessId}/analytics/status`,
|
|
1938
|
+
{
|
|
1939
|
+
...options,
|
|
1940
|
+
params
|
|
1941
|
+
}
|
|
1942
|
+
);
|
|
1943
|
+
}
|
|
1944
|
+
};
|
|
1945
|
+
};
|
|
1946
|
+
|
|
1869
1947
|
// src/api/storefront.ts
|
|
1870
1948
|
function groupCartToItems(cart) {
|
|
1871
1949
|
const groups = /* @__PURE__ */ new Map();
|
|
@@ -2712,7 +2790,7 @@ function getFirstAvailableFCId(variant, quantity = 1) {
|
|
|
2712
2790
|
}
|
|
2713
2791
|
|
|
2714
2792
|
// src/index.ts
|
|
2715
|
-
var SDK_VERSION = "0.7.
|
|
2793
|
+
var SDK_VERSION = "0.7.67";
|
|
2716
2794
|
var SUPPORTED_FRAMEWORKS = [
|
|
2717
2795
|
"astro",
|
|
2718
2796
|
"react",
|
|
@@ -2762,15 +2840,19 @@ function createUtilitySurface(apiConfig) {
|
|
|
2762
2840
|
}
|
|
2763
2841
|
async function createAdmin(config) {
|
|
2764
2842
|
const locale = config.locale || "en";
|
|
2765
|
-
const
|
|
2843
|
+
const getToken = config.getToken || defaultGetToken;
|
|
2844
|
+
const setToken = config.setToken || defaultSetToken;
|
|
2845
|
+
const logout = config.logout || defaultLogout;
|
|
2846
|
+
const isAuthenticated = config.isAuthenticated || defaultIsAuthenticated;
|
|
2847
|
+
const httpClient = createHttpClient({ ...config, getToken, setToken, logout });
|
|
2766
2848
|
const apiConfig = {
|
|
2767
2849
|
httpClient,
|
|
2768
2850
|
businessId: config.businessId,
|
|
2769
2851
|
baseUrl: config.baseUrl,
|
|
2770
2852
|
market: config.market,
|
|
2771
2853
|
locale,
|
|
2772
|
-
setToken
|
|
2773
|
-
getToken
|
|
2854
|
+
setToken,
|
|
2855
|
+
getToken
|
|
2774
2856
|
};
|
|
2775
2857
|
const accountApi = createAccountApi(apiConfig);
|
|
2776
2858
|
const authApi = createAuthApi(apiConfig);
|
|
@@ -2799,6 +2881,7 @@ async function createAdmin(config) {
|
|
|
2799
2881
|
const formApi = createFormApi(apiConfig);
|
|
2800
2882
|
const taxonomyApi = createTaxonomyApi(apiConfig);
|
|
2801
2883
|
const emailTemplateApi = createEmailTemplateApi(apiConfig);
|
|
2884
|
+
const analyticsApi = createAnalyticsApi(apiConfig);
|
|
2802
2885
|
const sdk = {
|
|
2803
2886
|
auth: authApi,
|
|
2804
2887
|
account: accountApi,
|
|
@@ -2945,7 +3028,11 @@ async function createAdmin(config) {
|
|
|
2945
3028
|
}
|
|
2946
3029
|
},
|
|
2947
3030
|
analytics: {
|
|
2948
|
-
track
|
|
3031
|
+
track,
|
|
3032
|
+
getSummary: analyticsApi.getSummary,
|
|
3033
|
+
getSeries: analyticsApi.getSeries,
|
|
3034
|
+
getTopEntities: analyticsApi.getTopEntities,
|
|
3035
|
+
getStatusBreakdown: analyticsApi.getStatusBreakdown
|
|
2949
3036
|
},
|
|
2950
3037
|
setBusinessId: (businessId) => {
|
|
2951
3038
|
apiConfig.businessId = businessId;
|
|
@@ -2959,9 +3046,9 @@ async function createAdmin(config) {
|
|
|
2959
3046
|
apiConfig.locale = locale2;
|
|
2960
3047
|
},
|
|
2961
3048
|
getLocale: () => apiConfig.locale,
|
|
2962
|
-
isAuthenticated
|
|
2963
|
-
logout
|
|
2964
|
-
setToken
|
|
3049
|
+
isAuthenticated,
|
|
3050
|
+
logout,
|
|
3051
|
+
setToken,
|
|
2965
3052
|
extractBlockValues,
|
|
2966
3053
|
utils: createUtilitySurface(apiConfig)
|
|
2967
3054
|
};
|
|
@@ -2969,8 +3056,15 @@ async function createAdmin(config) {
|
|
|
2969
3056
|
}
|
|
2970
3057
|
async function createStorefront(config) {
|
|
2971
3058
|
const locale = config.locale || "en";
|
|
3059
|
+
const getToken = config.getToken || defaultGetToken;
|
|
3060
|
+
const setToken = config.setToken || defaultSetToken;
|
|
3061
|
+
const logout = config.logout || defaultLogout;
|
|
3062
|
+
const isAuthenticated = config.isAuthenticated || defaultIsAuthenticated;
|
|
2972
3063
|
const httpClient = createHttpClient({
|
|
2973
3064
|
...config,
|
|
3065
|
+
getToken,
|
|
3066
|
+
setToken,
|
|
3067
|
+
logout,
|
|
2974
3068
|
refreshPath: `/v1/storefront/${config.businessId}/customers/auth/refresh`
|
|
2975
3069
|
});
|
|
2976
3070
|
const apiConfig = {
|
|
@@ -2979,8 +3073,8 @@ async function createStorefront(config) {
|
|
|
2979
3073
|
baseUrl: config.baseUrl,
|
|
2980
3074
|
market: config.market,
|
|
2981
3075
|
locale,
|
|
2982
|
-
setToken
|
|
2983
|
-
getToken
|
|
3076
|
+
setToken,
|
|
3077
|
+
getToken
|
|
2984
3078
|
};
|
|
2985
3079
|
const storefrontApi = createStorefrontApi(apiConfig);
|
|
2986
3080
|
let sessionPromise = null;
|
|
@@ -3036,9 +3130,9 @@ async function createStorefront(config) {
|
|
|
3036
3130
|
apiConfig.locale = locale2;
|
|
3037
3131
|
},
|
|
3038
3132
|
getLocale: () => apiConfig.locale,
|
|
3039
|
-
isAuthenticated
|
|
3040
|
-
logout
|
|
3041
|
-
setToken
|
|
3133
|
+
isAuthenticated,
|
|
3134
|
+
logout,
|
|
3135
|
+
setToken,
|
|
3042
3136
|
extractBlockValues,
|
|
3043
3137
|
utils: createUtilitySurface(apiConfig)
|
|
3044
3138
|
};
|