arky-sdk 0.8.0 → 0.9.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.
@@ -81,67 +81,35 @@ interface TrackParams {
81
81
  declare const COMMON_ACTIVITY_TYPES: readonly ["page_view", "product_view", "service_view", "provider_view", "cart_added", "cart_removed", "checkout_started", "purchase", "order_created", "signin", "signup", "verified_email", "search", "share", "wishlist_added"];
82
82
  type CommonActivityType = (typeof COMMON_ACTIVITY_TYPES)[number];
83
83
 
84
- type EntityKind = "product" | "service" | "provider" | "node" | "customer" | "audience" | "agent" | "workflow" | "promo_code" | "email_template" | "form" | "taxonomy" | "media" | "order";
85
- type Granularity = "hour" | "day" | "week" | "month" | {
86
- minutes: 5 | 10 | 15 | 30;
87
- };
88
- type Measure = "count" | "uniq_customers" | "orders_created" | "new_customers" | "form_submissions" | {
89
- entity_state: {
90
- entity: EntityKind;
91
- status: string;
92
- };
93
- };
94
- type Dimension = "country_code" | "city" | "device_type" | "browser" | "os" | "language" | "activity_type" | "entity" | "entity_status" | {
95
- time_bucket: {
96
- granularity: Granularity;
97
- };
98
- };
99
- type FilterField = "type" | "country_code" | "device_type" | "browser" | "os" | "language" | "entity" | "action" | "customer_id";
100
- type FilterOp = "eq" | "neq" | "in" | "not_in" | "contains";
101
- interface Filter {
102
- field: FilterField;
103
- op: FilterOp;
104
- values: string[];
105
- }
106
- type TimeUnit = "hour" | "day" | "week" | "month";
107
- type TimeRange = {
108
- from: number;
109
- unit: TimeUnit;
110
- to?: number;
111
- } | {
84
+ interface AnalyticsTimeRange {
112
85
  from: number;
113
86
  to: number;
114
- };
115
- interface OrderBy {
116
- field: string;
117
- dir: "asc" | "desc";
118
- }
119
- interface AnalyticsQuery {
120
- measures: Measure[];
121
- dimensions?: Dimension[];
122
- filters?: Filter[];
123
- time_range: TimeRange;
124
- granularity?: Granularity;
125
- order_by?: OrderBy[];
126
- limit?: number;
127
- }
128
- interface AnalyticsRow {
129
- [key: string]: string | number | null;
130
- }
131
- interface AnalyticsQueryResponse {
132
- rows: AnalyticsRow[];
133
- meta: {
134
- row_count: number;
135
- execution_ms: number;
136
- };
137
87
  }
88
+ type AnalyticsReportKey = "orders_created" | "customers_created" | "form_submissions_created" | "carts_abandoned" | "media_count" | "products_by_status" | "services_by_status" | "providers_by_status" | "nodes_by_status" | "customers_by_status" | "audiences_by_status" | "agents_by_status" | "workflows_by_status" | "promo_codes_by_status" | "email_templates_by_status" | "forms_by_status" | "taxonomies_by_status" | "carts_by_status" | "orders_by_status" | "order_items_by_status" | "activity_by_country" | "recent_activity";
138
89
  type ActivityFeedCategory = "orders" | "carts" | "promo_codes" | "submissions" | "customers" | "audiences" | "products" | "services" | "providers" | "cms" | "workflows" | "agents" | "activities";
139
- interface ActivityFeedQuery {
90
+ interface AnalyticsReportRequest {
91
+ key: AnalyticsReportKey;
140
92
  limit?: number;
141
- since?: number;
93
+ category?: ActivityFeedCategory;
142
94
  cursor_created_at?: number;
143
95
  cursor_id?: string;
144
- category?: ActivityFeedCategory;
96
+ }
97
+ interface AnalyticsRequest {
98
+ time: AnalyticsTimeRange;
99
+ reports: AnalyticsReportRequest[];
100
+ }
101
+ interface AnalyticsMetricData {
102
+ value: number;
103
+ execution_ms?: number;
104
+ }
105
+ interface AnalyticsBreakdownItem {
106
+ key: string;
107
+ label: string;
108
+ value: number;
109
+ unique_customers?: number;
110
+ }
111
+ interface AnalyticsBreakdownData {
112
+ items: AnalyticsBreakdownItem[];
145
113
  }
146
114
  interface ActivityFeedItem {
147
115
  id: string;
@@ -155,7 +123,6 @@ interface ActivityFeedItem {
155
123
  title: string;
156
124
  description: string;
157
125
  href?: string | null;
158
- booking_count: number;
159
126
  data: unknown;
160
127
  payload: unknown;
161
128
  created_at: number;
@@ -182,7 +149,7 @@ interface ActivityFeedCursor {
182
149
  created_at: number;
183
150
  id: string;
184
151
  }
185
- interface ActivityFeedResponse {
152
+ interface ActivityFeedData {
186
153
  items: ActivityFeedItem[];
187
154
  summary: ActivityFeedSummary;
188
155
  next_cursor?: ActivityFeedCursor | null;
@@ -191,6 +158,23 @@ interface ActivityFeedResponse {
191
158
  execution_ms: number;
192
159
  };
193
160
  }
161
+ type AnalyticsReport = {
162
+ key: AnalyticsReportKey;
163
+ type: "metric";
164
+ data: AnalyticsMetricData;
165
+ } | {
166
+ key: AnalyticsReportKey;
167
+ type: "breakdown";
168
+ data: AnalyticsBreakdownData;
169
+ } | {
170
+ key: AnalyticsReportKey;
171
+ type: "activity";
172
+ data: ActivityFeedData;
173
+ };
174
+ interface AnalyticsResponse {
175
+ time: AnalyticsTimeRange;
176
+ reports: AnalyticsReport[];
177
+ }
194
178
 
195
179
  interface Activity {
196
180
  id: string;
@@ -762,12 +746,9 @@ declare function createAdmin(config: CreateAdminConfig): {
762
746
  };
763
747
  };
764
748
  analytics: {
765
- query: (spec: AnalyticsQuery, options?: RequestOptions$1 & {
766
- store_id?: string;
767
- }) => Promise<AnalyticsQueryResponse>;
768
- activityFeed: (query?: ActivityFeedQuery, options?: RequestOptions$1 & {
749
+ get(request: AnalyticsRequest, options?: RequestOptions$1 & {
769
750
  store_id?: string;
770
- }) => Promise<ActivityFeedResponse>;
751
+ }): Promise<AnalyticsResponse>;
771
752
  };
772
753
  setStoreId: (storeId: string) => void;
773
754
  getStoreId: () => string;
@@ -1052,4 +1033,4 @@ declare function createStorefront(config: CreateStorefrontConfig): {
1052
1033
  };
1053
1034
  };
1054
1035
 
1055
- export { type AnalyticsQueryResponse as $, type AuthStateListener as A, type CartControllerListener as B, type CreateStorefrontConfig as C, type CartControllerQuoteParams as D, type CartControllerRefreshParams as E, type CartControllerRemoveItemParams as F, type CartControllerState as G, type CartControllerUpdateParams as H, type IdentifyResponse as I, type HttpClientConfig as J, type AuthStorage as K, SUPPORTED_FRAMEWORKS as L, type ApiConfig as M, type AdminSessionInternal as N, type CustomerSessionInternal as O, type AdminSession as P, type AdminSessionUpdater as Q, type CustomerSessionUpdater as R, SDK_VERSION as S, type TrackParams as T, type CreateAdminConfig as U, type VerifyResponse as V, createAdmin as W, type LocationState as X, type LocationCountry as Y, type GetCountriesResponse as Z, type AnalyticsQuery as _, type CustomerSession as a, type AnalyticsRow as a0, type Measure as a1, type Dimension as a2, type Filter as a3, type FilterField as a4, type FilterOp as a5, type Granularity as a6, type EntityKind as a7, type TimeRange as a8, type TimeUnit as a9, type OrderBy as aa, type ActivityFeedCategory as ab, type ActivityFeedQuery as ac, type ActivityFeedItem as ad, type ActivityFeedSummary as ae, type ActivityFeedCursor as af, type ActivityFeedResponse as ag, type TimelineParams as ah, type IntegrationOperation as ai, type IntegrationResource as aj, type IntegrationService as ak, type CustomerToken as b, type CartController as c, findTimeZone as d, extractBlockValues as e, formatBlockValue as f, getBlockLabel as g, humanize as h, categorify as i, formatDate as j, getSvgContentForAstro as k, fetchSvgContent as l, injectSvgIntoElement as m, type Activity$1 as n, COMMON_ACTIVITY_TYPES as o, prepareBlocksForSubmission as p, createStorefront as q, createCartController as r, slugify as s, type CommonActivityType as t, type CartApi as u, validatePhoneNumber as v, type CartControllerAddItemParams as w, type CartControllerCheckoutParams as x, type CartControllerClearParams as y, type CartControllerInitParams as z };
1036
+ export { type AnalyticsReportKey as $, type AuthStateListener as A, type CartControllerListener as B, type CreateStorefrontConfig as C, type CartControllerQuoteParams as D, type CartControllerRefreshParams as E, type CartControllerRemoveItemParams as F, type CartControllerState as G, type CartControllerUpdateParams as H, type IdentifyResponse as I, type HttpClientConfig as J, type AuthStorage as K, SUPPORTED_FRAMEWORKS as L, type ApiConfig as M, type AdminSessionInternal as N, type CustomerSessionInternal as O, type AdminSession as P, type AdminSessionUpdater as Q, type CustomerSessionUpdater as R, SDK_VERSION as S, type TrackParams as T, type CreateAdminConfig as U, type VerifyResponse as V, createAdmin as W, type LocationState as X, type LocationCountry as Y, type GetCountriesResponse as Z, type AnalyticsTimeRange as _, type CustomerSession as a, type AnalyticsReportRequest as a0, type AnalyticsRequest as a1, type AnalyticsMetricData as a2, type AnalyticsBreakdownItem as a3, type AnalyticsBreakdownData as a4, type AnalyticsReport as a5, type AnalyticsResponse as a6, type ActivityFeedCategory as a7, type ActivityFeedItem as a8, type ActivityFeedSummary as a9, type ActivityFeedCursor as aa, type ActivityFeedData as ab, type TimelineParams as ac, type IntegrationOperation as ad, type IntegrationResource as ae, type IntegrationService as af, type CustomerToken as b, type CartController as c, findTimeZone as d, extractBlockValues as e, formatBlockValue as f, getBlockLabel as g, humanize as h, categorify as i, formatDate as j, getSvgContentForAstro as k, fetchSvgContent as l, injectSvgIntoElement as m, type Activity$1 as n, COMMON_ACTIVITY_TYPES as o, prepareBlocksForSubmission as p, createStorefront as q, createCartController as r, slugify as s, type CommonActivityType as t, type CartApi as u, validatePhoneNumber as v, type CartControllerAddItemParams as w, type CartControllerCheckoutParams as x, type CartControllerClearParams as y, type CartControllerInitParams as z };
@@ -81,67 +81,35 @@ interface TrackParams {
81
81
  declare const COMMON_ACTIVITY_TYPES: readonly ["page_view", "product_view", "service_view", "provider_view", "cart_added", "cart_removed", "checkout_started", "purchase", "order_created", "signin", "signup", "verified_email", "search", "share", "wishlist_added"];
82
82
  type CommonActivityType = (typeof COMMON_ACTIVITY_TYPES)[number];
83
83
 
84
- type EntityKind = "product" | "service" | "provider" | "node" | "customer" | "audience" | "agent" | "workflow" | "promo_code" | "email_template" | "form" | "taxonomy" | "media" | "order";
85
- type Granularity = "hour" | "day" | "week" | "month" | {
86
- minutes: 5 | 10 | 15 | 30;
87
- };
88
- type Measure = "count" | "uniq_customers" | "orders_created" | "new_customers" | "form_submissions" | {
89
- entity_state: {
90
- entity: EntityKind;
91
- status: string;
92
- };
93
- };
94
- type Dimension = "country_code" | "city" | "device_type" | "browser" | "os" | "language" | "activity_type" | "entity" | "entity_status" | {
95
- time_bucket: {
96
- granularity: Granularity;
97
- };
98
- };
99
- type FilterField = "type" | "country_code" | "device_type" | "browser" | "os" | "language" | "entity" | "action" | "customer_id";
100
- type FilterOp = "eq" | "neq" | "in" | "not_in" | "contains";
101
- interface Filter {
102
- field: FilterField;
103
- op: FilterOp;
104
- values: string[];
105
- }
106
- type TimeUnit = "hour" | "day" | "week" | "month";
107
- type TimeRange = {
108
- from: number;
109
- unit: TimeUnit;
110
- to?: number;
111
- } | {
84
+ interface AnalyticsTimeRange {
112
85
  from: number;
113
86
  to: number;
114
- };
115
- interface OrderBy {
116
- field: string;
117
- dir: "asc" | "desc";
118
- }
119
- interface AnalyticsQuery {
120
- measures: Measure[];
121
- dimensions?: Dimension[];
122
- filters?: Filter[];
123
- time_range: TimeRange;
124
- granularity?: Granularity;
125
- order_by?: OrderBy[];
126
- limit?: number;
127
- }
128
- interface AnalyticsRow {
129
- [key: string]: string | number | null;
130
- }
131
- interface AnalyticsQueryResponse {
132
- rows: AnalyticsRow[];
133
- meta: {
134
- row_count: number;
135
- execution_ms: number;
136
- };
137
87
  }
88
+ type AnalyticsReportKey = "orders_created" | "customers_created" | "form_submissions_created" | "carts_abandoned" | "media_count" | "products_by_status" | "services_by_status" | "providers_by_status" | "nodes_by_status" | "customers_by_status" | "audiences_by_status" | "agents_by_status" | "workflows_by_status" | "promo_codes_by_status" | "email_templates_by_status" | "forms_by_status" | "taxonomies_by_status" | "carts_by_status" | "orders_by_status" | "order_items_by_status" | "activity_by_country" | "recent_activity";
138
89
  type ActivityFeedCategory = "orders" | "carts" | "promo_codes" | "submissions" | "customers" | "audiences" | "products" | "services" | "providers" | "cms" | "workflows" | "agents" | "activities";
139
- interface ActivityFeedQuery {
90
+ interface AnalyticsReportRequest {
91
+ key: AnalyticsReportKey;
140
92
  limit?: number;
141
- since?: number;
93
+ category?: ActivityFeedCategory;
142
94
  cursor_created_at?: number;
143
95
  cursor_id?: string;
144
- category?: ActivityFeedCategory;
96
+ }
97
+ interface AnalyticsRequest {
98
+ time: AnalyticsTimeRange;
99
+ reports: AnalyticsReportRequest[];
100
+ }
101
+ interface AnalyticsMetricData {
102
+ value: number;
103
+ execution_ms?: number;
104
+ }
105
+ interface AnalyticsBreakdownItem {
106
+ key: string;
107
+ label: string;
108
+ value: number;
109
+ unique_customers?: number;
110
+ }
111
+ interface AnalyticsBreakdownData {
112
+ items: AnalyticsBreakdownItem[];
145
113
  }
146
114
  interface ActivityFeedItem {
147
115
  id: string;
@@ -155,7 +123,6 @@ interface ActivityFeedItem {
155
123
  title: string;
156
124
  description: string;
157
125
  href?: string | null;
158
- booking_count: number;
159
126
  data: unknown;
160
127
  payload: unknown;
161
128
  created_at: number;
@@ -182,7 +149,7 @@ interface ActivityFeedCursor {
182
149
  created_at: number;
183
150
  id: string;
184
151
  }
185
- interface ActivityFeedResponse {
152
+ interface ActivityFeedData {
186
153
  items: ActivityFeedItem[];
187
154
  summary: ActivityFeedSummary;
188
155
  next_cursor?: ActivityFeedCursor | null;
@@ -191,6 +158,23 @@ interface ActivityFeedResponse {
191
158
  execution_ms: number;
192
159
  };
193
160
  }
161
+ type AnalyticsReport = {
162
+ key: AnalyticsReportKey;
163
+ type: "metric";
164
+ data: AnalyticsMetricData;
165
+ } | {
166
+ key: AnalyticsReportKey;
167
+ type: "breakdown";
168
+ data: AnalyticsBreakdownData;
169
+ } | {
170
+ key: AnalyticsReportKey;
171
+ type: "activity";
172
+ data: ActivityFeedData;
173
+ };
174
+ interface AnalyticsResponse {
175
+ time: AnalyticsTimeRange;
176
+ reports: AnalyticsReport[];
177
+ }
194
178
 
195
179
  interface Activity {
196
180
  id: string;
@@ -762,12 +746,9 @@ declare function createAdmin(config: CreateAdminConfig): {
762
746
  };
763
747
  };
764
748
  analytics: {
765
- query: (spec: AnalyticsQuery, options?: RequestOptions$1 & {
766
- store_id?: string;
767
- }) => Promise<AnalyticsQueryResponse>;
768
- activityFeed: (query?: ActivityFeedQuery, options?: RequestOptions$1 & {
749
+ get(request: AnalyticsRequest, options?: RequestOptions$1 & {
769
750
  store_id?: string;
770
- }) => Promise<ActivityFeedResponse>;
751
+ }): Promise<AnalyticsResponse>;
771
752
  };
772
753
  setStoreId: (storeId: string) => void;
773
754
  getStoreId: () => string;
@@ -1052,4 +1033,4 @@ declare function createStorefront(config: CreateStorefrontConfig): {
1052
1033
  };
1053
1034
  };
1054
1035
 
1055
- export { type AnalyticsQueryResponse as $, type AuthStateListener as A, type CartControllerListener as B, type CreateStorefrontConfig as C, type CartControllerQuoteParams as D, type CartControllerRefreshParams as E, type CartControllerRemoveItemParams as F, type CartControllerState as G, type CartControllerUpdateParams as H, type IdentifyResponse as I, type HttpClientConfig as J, type AuthStorage as K, SUPPORTED_FRAMEWORKS as L, type ApiConfig as M, type AdminSessionInternal as N, type CustomerSessionInternal as O, type AdminSession as P, type AdminSessionUpdater as Q, type CustomerSessionUpdater as R, SDK_VERSION as S, type TrackParams as T, type CreateAdminConfig as U, type VerifyResponse as V, createAdmin as W, type LocationState as X, type LocationCountry as Y, type GetCountriesResponse as Z, type AnalyticsQuery as _, type CustomerSession as a, type AnalyticsRow as a0, type Measure as a1, type Dimension as a2, type Filter as a3, type FilterField as a4, type FilterOp as a5, type Granularity as a6, type EntityKind as a7, type TimeRange as a8, type TimeUnit as a9, type OrderBy as aa, type ActivityFeedCategory as ab, type ActivityFeedQuery as ac, type ActivityFeedItem as ad, type ActivityFeedSummary as ae, type ActivityFeedCursor as af, type ActivityFeedResponse as ag, type TimelineParams as ah, type IntegrationOperation as ai, type IntegrationResource as aj, type IntegrationService as ak, type CustomerToken as b, type CartController as c, findTimeZone as d, extractBlockValues as e, formatBlockValue as f, getBlockLabel as g, humanize as h, categorify as i, formatDate as j, getSvgContentForAstro as k, fetchSvgContent as l, injectSvgIntoElement as m, type Activity$1 as n, COMMON_ACTIVITY_TYPES as o, prepareBlocksForSubmission as p, createStorefront as q, createCartController as r, slugify as s, type CommonActivityType as t, type CartApi as u, validatePhoneNumber as v, type CartControllerAddItemParams as w, type CartControllerCheckoutParams as x, type CartControllerClearParams as y, type CartControllerInitParams as z };
1036
+ export { type AnalyticsReportKey as $, type AuthStateListener as A, type CartControllerListener as B, type CreateStorefrontConfig as C, type CartControllerQuoteParams as D, type CartControllerRefreshParams as E, type CartControllerRemoveItemParams as F, type CartControllerState as G, type CartControllerUpdateParams as H, type IdentifyResponse as I, type HttpClientConfig as J, type AuthStorage as K, SUPPORTED_FRAMEWORKS as L, type ApiConfig as M, type AdminSessionInternal as N, type CustomerSessionInternal as O, type AdminSession as P, type AdminSessionUpdater as Q, type CustomerSessionUpdater as R, SDK_VERSION as S, type TrackParams as T, type CreateAdminConfig as U, type VerifyResponse as V, createAdmin as W, type LocationState as X, type LocationCountry as Y, type GetCountriesResponse as Z, type AnalyticsTimeRange as _, type CustomerSession as a, type AnalyticsReportRequest as a0, type AnalyticsRequest as a1, type AnalyticsMetricData as a2, type AnalyticsBreakdownItem as a3, type AnalyticsBreakdownData as a4, type AnalyticsReport as a5, type AnalyticsResponse as a6, type ActivityFeedCategory as a7, type ActivityFeedItem as a8, type ActivityFeedSummary as a9, type ActivityFeedCursor as aa, type ActivityFeedData as ab, type TimelineParams as ac, type IntegrationOperation as ad, type IntegrationResource as ae, type IntegrationService as af, type CustomerToken as b, type CartController as c, findTimeZone as d, extractBlockValues as e, formatBlockValue as f, getBlockLabel as g, humanize as h, categorify as i, formatDate as j, getSvgContentForAstro as k, fetchSvgContent as l, injectSvgIntoElement as m, type Activity$1 as n, COMMON_ACTIVITY_TYPES as o, prepareBlocksForSubmission as p, createStorefront as q, createCartController as r, slugify as s, type CommonActivityType as t, type CartApi as u, validatePhoneNumber as v, type CartControllerAddItemParams as w, type CartControllerCheckoutParams as x, type CartControllerClearParams as y, type CartControllerInitParams as z };
package/dist/admin.cjs CHANGED
@@ -1884,20 +1884,13 @@ var createTaxonomyApi = (apiConfig) => {
1884
1884
  // src/api/analytics.ts
1885
1885
  var createAnalyticsApi = (apiConfig) => {
1886
1886
  return {
1887
- async query(spec, options) {
1887
+ async get(request, options) {
1888
1888
  const store_id = options?.store_id || apiConfig.storeId;
1889
1889
  return apiConfig.httpClient.post(
1890
- `/v1/stores/${store_id}/analytics/query`,
1891
- spec,
1890
+ `/v1/stores/${store_id}/analytics`,
1891
+ request,
1892
1892
  options
1893
1893
  );
1894
- },
1895
- async activityFeed(query = {}, options) {
1896
- const store_id = options?.store_id || apiConfig.storeId;
1897
- return apiConfig.httpClient.get(
1898
- `/v1/stores/${store_id}/analytics/activity-feed`,
1899
- { ...options, params: query }
1900
- );
1901
1894
  }
1902
1895
  };
1903
1896
  };
@@ -2434,10 +2427,7 @@ function createAdmin(config) {
2434
2427
  getExecution: workflowApi.getWorkflowExecution
2435
2428
  }
2436
2429
  },
2437
- analytics: {
2438
- query: analyticsApi.query,
2439
- activityFeed: analyticsApi.activityFeed
2440
- },
2430
+ analytics: analyticsApi,
2441
2431
  setStoreId: (storeId) => {
2442
2432
  apiConfig.storeId = storeId;
2443
2433
  },