@aranova/tracking-react 0.20.2 → 0.21.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.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +23 -18
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +23 -18
- package/dist/index.mjs.map +1 -1
- package/dist/{sales-DrH6dY5F.d.mts → sales-CBQJ2SBT.d.mts} +21 -19
- package/dist/{sales-DrH6dY5F.d.ts → sales-CBQJ2SBT.d.ts} +21 -19
- package/dist/sales.d.mts +1 -1
- package/dist/sales.d.ts +1 -1
- package/dist/sales.js +22 -17
- package/dist/sales.js.map +1 -1
- package/dist/sales.mjs +22 -17
- package/dist/sales.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -815,14 +815,11 @@ interface BusinessConfig {
|
|
|
815
815
|
features: BusinessConfigFeatures;
|
|
816
816
|
}
|
|
817
817
|
|
|
818
|
-
/** Shared config for every
|
|
819
|
-
interface
|
|
818
|
+
/** Shared config for every awaited (non fire-and-forget) API helper. */
|
|
819
|
+
interface ApiTransportConfig {
|
|
820
820
|
/** Public (`aranv_pk_…`) or secret (`aranv_sk_…`) API key. */
|
|
821
821
|
apiKey: string;
|
|
822
|
-
/**
|
|
823
|
-
* Base tracking endpoint, e.g. `https://aranovainternal-production.up.railway.app/tracking`.
|
|
824
|
-
* The `/sales` path is appended by the helpers.
|
|
825
|
-
*/
|
|
822
|
+
/** Base tracking endpoint, e.g. `https://aranovainternal-production.up.railway.app/tracking`. */
|
|
826
823
|
endpoint: string;
|
|
827
824
|
/** Optional SDK identity headers (mirrors the event ingest client). */
|
|
828
825
|
sdkVersion?: string;
|
|
@@ -831,11 +828,13 @@ interface SalesTransportConfig {
|
|
|
831
828
|
environment?: string;
|
|
832
829
|
}
|
|
833
830
|
/**
|
|
834
|
-
* Single awaited request
|
|
835
|
-
*
|
|
836
|
-
* Returns `undefined` for 204 No Content.
|
|
831
|
+
* Single awaited request. Unlike the event queue, this surfaces failures: any
|
|
832
|
+
* non-2xx rejects with an {@link AranovaApiError}. Returns `undefined` for 204.
|
|
837
833
|
*/
|
|
838
|
-
declare function
|
|
834
|
+
declare function apiRequest<T>(config: ApiTransportConfig, method: string, path: string, body?: unknown, extraHeaders?: Record<string, string>): Promise<T>;
|
|
835
|
+
|
|
836
|
+
type SalesTransportConfig = ApiTransportConfig;
|
|
837
|
+
declare const salesRequest: typeof apiRequest;
|
|
839
838
|
|
|
840
839
|
/** Config for {@link createSalesClient}. */
|
|
841
840
|
interface SalesClientConfig extends SalesTransportConfig {
|
|
@@ -938,9 +937,11 @@ interface SalesClient<TService extends string = string, TConversion extends stri
|
|
|
938
937
|
declare function createSalesClient<TService extends string = string, TConversion extends string = string>(config: SalesClientConfig): SalesClient<TService, TConversion>;
|
|
939
938
|
|
|
940
939
|
/**
|
|
941
|
-
*
|
|
942
|
-
*
|
|
943
|
-
*
|
|
940
|
+
* Thrown on a non-2xx from any awaited Aranova API call.
|
|
941
|
+
*
|
|
942
|
+
* Lives here rather than inside one resource because more than one resource
|
|
943
|
+
* needs it, and a duplicate class would be a genuine hazard: a name star-exported
|
|
944
|
+
* from two modules is silently dropped unless both resolve to the same binding.
|
|
944
945
|
*/
|
|
945
946
|
declare class AranovaApiError extends Error {
|
|
946
947
|
readonly status: number;
|
|
@@ -953,6 +954,13 @@ declare class AranovaApiError extends Error {
|
|
|
953
954
|
});
|
|
954
955
|
}
|
|
955
956
|
|
|
957
|
+
/**
|
|
958
|
+
* Format an ISO timestamp in a specific IANA time zone (e.g. `America/Toronto`),
|
|
959
|
+
* so dashboards stop hand-rolling `Intl`. Defaults to a short date-time; pass
|
|
960
|
+
* `opts` to override fields. The `timeZone` is always forced to the argument.
|
|
961
|
+
*/
|
|
962
|
+
declare function formatDateInTz(iso: string, timeZone: string, opts?: Intl.DateTimeFormatOptions, locale?: string): string;
|
|
963
|
+
|
|
956
964
|
/**
|
|
957
965
|
* Convert a major amount (dollars `250.5`) to integer minor units (`25050`).
|
|
958
966
|
*
|
|
@@ -969,12 +977,6 @@ declare function fromMinor(cents: number, currency: SupportedCurrency): number;
|
|
|
969
977
|
* Uses the built-in `Intl.NumberFormat` — no extra dependency.
|
|
970
978
|
*/
|
|
971
979
|
declare function formatMoney(cents: number, currency: SupportedCurrency, locale?: string): string;
|
|
972
|
-
/**
|
|
973
|
-
* Format an ISO timestamp in a specific IANA time zone (e.g. `America/Toronto`),
|
|
974
|
-
* so dashboards stop hand-rolling `Intl`. Defaults to a short date-time; pass
|
|
975
|
-
* `opts` to override fields. The `timeZone` is always forced to the argument.
|
|
976
|
-
*/
|
|
977
|
-
declare function formatDateInTz(iso: string, timeZone: string, opts?: Intl.DateTimeFormatOptions, locale?: string): string;
|
|
978
980
|
|
|
979
981
|
/** A business's active service, as returned by `GET /tracking/services`. */
|
|
980
982
|
interface PublicServiceItem {
|
|
@@ -815,14 +815,11 @@ interface BusinessConfig {
|
|
|
815
815
|
features: BusinessConfigFeatures;
|
|
816
816
|
}
|
|
817
817
|
|
|
818
|
-
/** Shared config for every
|
|
819
|
-
interface
|
|
818
|
+
/** Shared config for every awaited (non fire-and-forget) API helper. */
|
|
819
|
+
interface ApiTransportConfig {
|
|
820
820
|
/** Public (`aranv_pk_…`) or secret (`aranv_sk_…`) API key. */
|
|
821
821
|
apiKey: string;
|
|
822
|
-
/**
|
|
823
|
-
* Base tracking endpoint, e.g. `https://aranovainternal-production.up.railway.app/tracking`.
|
|
824
|
-
* The `/sales` path is appended by the helpers.
|
|
825
|
-
*/
|
|
822
|
+
/** Base tracking endpoint, e.g. `https://aranovainternal-production.up.railway.app/tracking`. */
|
|
826
823
|
endpoint: string;
|
|
827
824
|
/** Optional SDK identity headers (mirrors the event ingest client). */
|
|
828
825
|
sdkVersion?: string;
|
|
@@ -831,11 +828,13 @@ interface SalesTransportConfig {
|
|
|
831
828
|
environment?: string;
|
|
832
829
|
}
|
|
833
830
|
/**
|
|
834
|
-
* Single awaited request
|
|
835
|
-
*
|
|
836
|
-
* Returns `undefined` for 204 No Content.
|
|
831
|
+
* Single awaited request. Unlike the event queue, this surfaces failures: any
|
|
832
|
+
* non-2xx rejects with an {@link AranovaApiError}. Returns `undefined` for 204.
|
|
837
833
|
*/
|
|
838
|
-
declare function
|
|
834
|
+
declare function apiRequest<T>(config: ApiTransportConfig, method: string, path: string, body?: unknown, extraHeaders?: Record<string, string>): Promise<T>;
|
|
835
|
+
|
|
836
|
+
type SalesTransportConfig = ApiTransportConfig;
|
|
837
|
+
declare const salesRequest: typeof apiRequest;
|
|
839
838
|
|
|
840
839
|
/** Config for {@link createSalesClient}. */
|
|
841
840
|
interface SalesClientConfig extends SalesTransportConfig {
|
|
@@ -938,9 +937,11 @@ interface SalesClient<TService extends string = string, TConversion extends stri
|
|
|
938
937
|
declare function createSalesClient<TService extends string = string, TConversion extends string = string>(config: SalesClientConfig): SalesClient<TService, TConversion>;
|
|
939
938
|
|
|
940
939
|
/**
|
|
941
|
-
*
|
|
942
|
-
*
|
|
943
|
-
*
|
|
940
|
+
* Thrown on a non-2xx from any awaited Aranova API call.
|
|
941
|
+
*
|
|
942
|
+
* Lives here rather than inside one resource because more than one resource
|
|
943
|
+
* needs it, and a duplicate class would be a genuine hazard: a name star-exported
|
|
944
|
+
* from two modules is silently dropped unless both resolve to the same binding.
|
|
944
945
|
*/
|
|
945
946
|
declare class AranovaApiError extends Error {
|
|
946
947
|
readonly status: number;
|
|
@@ -953,6 +954,13 @@ declare class AranovaApiError extends Error {
|
|
|
953
954
|
});
|
|
954
955
|
}
|
|
955
956
|
|
|
957
|
+
/**
|
|
958
|
+
* Format an ISO timestamp in a specific IANA time zone (e.g. `America/Toronto`),
|
|
959
|
+
* so dashboards stop hand-rolling `Intl`. Defaults to a short date-time; pass
|
|
960
|
+
* `opts` to override fields. The `timeZone` is always forced to the argument.
|
|
961
|
+
*/
|
|
962
|
+
declare function formatDateInTz(iso: string, timeZone: string, opts?: Intl.DateTimeFormatOptions, locale?: string): string;
|
|
963
|
+
|
|
956
964
|
/**
|
|
957
965
|
* Convert a major amount (dollars `250.5`) to integer minor units (`25050`).
|
|
958
966
|
*
|
|
@@ -969,12 +977,6 @@ declare function fromMinor(cents: number, currency: SupportedCurrency): number;
|
|
|
969
977
|
* Uses the built-in `Intl.NumberFormat` — no extra dependency.
|
|
970
978
|
*/
|
|
971
979
|
declare function formatMoney(cents: number, currency: SupportedCurrency, locale?: string): string;
|
|
972
|
-
/**
|
|
973
|
-
* Format an ISO timestamp in a specific IANA time zone (e.g. `America/Toronto`),
|
|
974
|
-
* so dashboards stop hand-rolling `Intl`. Defaults to a short date-time; pass
|
|
975
|
-
* `opts` to override fields. The `timeZone` is always forced to the argument.
|
|
976
|
-
*/
|
|
977
|
-
declare function formatDateInTz(iso: string, timeZone: string, opts?: Intl.DateTimeFormatOptions, locale?: string): string;
|
|
978
980
|
|
|
979
981
|
/** A business's active service, as returned by `GET /tracking/services`. */
|
|
980
982
|
interface PublicServiceItem {
|
package/dist/sales.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { A as AranovaApiError, B as BusinessConfig, a as BusinessConfigFeatures, b as BusinessConfigService, c as CompareTo, f as CurrencyRevenue, g as CustomerCurrencyDelta, h as CustomerCurrencyTotal, i as CustomerGetOptions, j as CustomerGetResult, k as CustomerKpis, l as CustomerKpisDeltas, m as CustomerKpisPrevious, n as CustomerListPage, o as CustomerListQuery, p as CustomerProfile, q as CustomerSegment, r as CustomerSegmentCount, s as CustomerSortField, t as CustomerSummary, u as CustomerSummaryQuery, D as DistinctCustomersByCurrency, G as Granularity, N as NAMED_RANGES, v as NamedRange, P as PublicServiceItem, S as SUPPORTED_CURRENCIES, w as Sale, x as SaleCursorPage, y as SaleFilters, z as SaleInput, E as SaleItem, F as SaleItemInput, H as SaleKeysetSortField, I as SaleListPage, J as SaleListQuery, K as SaleListQueryV2, L as SaleService, M as SaleServiceInput, O as SaleSortField, Q as SaleSortOrder, R as SaleSummary, U as SaleSummaryPrevious, V as SaleSummaryQuery, W as SaleSummaryQueryV2, X as SaleSummaryV2, Y as SaleUpdateInput, Z as SalesBusinessClient, _ as SalesCategoryBreakdown, $ as SalesClient, a0 as SalesClientConfig, a1 as SalesCustomersClient, a2 as SalesServiceBreakdown, a3 as SalesTransportConfig, a4 as SalesTrendPoint, a5 as SummaryCurrencyDelta, a6 as SummaryDeltas, a7 as SummaryWindow, a8 as SupportedCurrency, a9 as TRACKING_RANGES, aa as TrackingOverviewRange, ac as createSalesClient, ad as fetchServices, ae as formatDateInTz, af as formatMoney, ag as fromMinor, aj as saleCreateSchema, ak as saleItemSchema, al as saleServiceSchema, am as saleUpdateSchema, an as salesRequest, ap as toMinor } from './sales-
|
|
1
|
+
export { A as AranovaApiError, B as BusinessConfig, a as BusinessConfigFeatures, b as BusinessConfigService, c as CompareTo, f as CurrencyRevenue, g as CustomerCurrencyDelta, h as CustomerCurrencyTotal, i as CustomerGetOptions, j as CustomerGetResult, k as CustomerKpis, l as CustomerKpisDeltas, m as CustomerKpisPrevious, n as CustomerListPage, o as CustomerListQuery, p as CustomerProfile, q as CustomerSegment, r as CustomerSegmentCount, s as CustomerSortField, t as CustomerSummary, u as CustomerSummaryQuery, D as DistinctCustomersByCurrency, G as Granularity, N as NAMED_RANGES, v as NamedRange, P as PublicServiceItem, S as SUPPORTED_CURRENCIES, w as Sale, x as SaleCursorPage, y as SaleFilters, z as SaleInput, E as SaleItem, F as SaleItemInput, H as SaleKeysetSortField, I as SaleListPage, J as SaleListQuery, K as SaleListQueryV2, L as SaleService, M as SaleServiceInput, O as SaleSortField, Q as SaleSortOrder, R as SaleSummary, U as SaleSummaryPrevious, V as SaleSummaryQuery, W as SaleSummaryQueryV2, X as SaleSummaryV2, Y as SaleUpdateInput, Z as SalesBusinessClient, _ as SalesCategoryBreakdown, $ as SalesClient, a0 as SalesClientConfig, a1 as SalesCustomersClient, a2 as SalesServiceBreakdown, a3 as SalesTransportConfig, a4 as SalesTrendPoint, a5 as SummaryCurrencyDelta, a6 as SummaryDeltas, a7 as SummaryWindow, a8 as SupportedCurrency, a9 as TRACKING_RANGES, aa as TrackingOverviewRange, ac as createSalesClient, ad as fetchServices, ae as formatDateInTz, af as formatMoney, ag as fromMinor, aj as saleCreateSchema, ak as saleItemSchema, al as saleServiceSchema, am as saleUpdateSchema, an as salesRequest, ap as toMinor } from './sales-CBQJ2SBT.mjs';
|
|
2
2
|
import 'zod';
|
|
3
3
|
import 'libphonenumber-js';
|
package/dist/sales.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { A as AranovaApiError, B as BusinessConfig, a as BusinessConfigFeatures, b as BusinessConfigService, c as CompareTo, f as CurrencyRevenue, g as CustomerCurrencyDelta, h as CustomerCurrencyTotal, i as CustomerGetOptions, j as CustomerGetResult, k as CustomerKpis, l as CustomerKpisDeltas, m as CustomerKpisPrevious, n as CustomerListPage, o as CustomerListQuery, p as CustomerProfile, q as CustomerSegment, r as CustomerSegmentCount, s as CustomerSortField, t as CustomerSummary, u as CustomerSummaryQuery, D as DistinctCustomersByCurrency, G as Granularity, N as NAMED_RANGES, v as NamedRange, P as PublicServiceItem, S as SUPPORTED_CURRENCIES, w as Sale, x as SaleCursorPage, y as SaleFilters, z as SaleInput, E as SaleItem, F as SaleItemInput, H as SaleKeysetSortField, I as SaleListPage, J as SaleListQuery, K as SaleListQueryV2, L as SaleService, M as SaleServiceInput, O as SaleSortField, Q as SaleSortOrder, R as SaleSummary, U as SaleSummaryPrevious, V as SaleSummaryQuery, W as SaleSummaryQueryV2, X as SaleSummaryV2, Y as SaleUpdateInput, Z as SalesBusinessClient, _ as SalesCategoryBreakdown, $ as SalesClient, a0 as SalesClientConfig, a1 as SalesCustomersClient, a2 as SalesServiceBreakdown, a3 as SalesTransportConfig, a4 as SalesTrendPoint, a5 as SummaryCurrencyDelta, a6 as SummaryDeltas, a7 as SummaryWindow, a8 as SupportedCurrency, a9 as TRACKING_RANGES, aa as TrackingOverviewRange, ac as createSalesClient, ad as fetchServices, ae as formatDateInTz, af as formatMoney, ag as fromMinor, aj as saleCreateSchema, ak as saleItemSchema, al as saleServiceSchema, am as saleUpdateSchema, an as salesRequest, ap as toMinor } from './sales-
|
|
1
|
+
export { A as AranovaApiError, B as BusinessConfig, a as BusinessConfigFeatures, b as BusinessConfigService, c as CompareTo, f as CurrencyRevenue, g as CustomerCurrencyDelta, h as CustomerCurrencyTotal, i as CustomerGetOptions, j as CustomerGetResult, k as CustomerKpis, l as CustomerKpisDeltas, m as CustomerKpisPrevious, n as CustomerListPage, o as CustomerListQuery, p as CustomerProfile, q as CustomerSegment, r as CustomerSegmentCount, s as CustomerSortField, t as CustomerSummary, u as CustomerSummaryQuery, D as DistinctCustomersByCurrency, G as Granularity, N as NAMED_RANGES, v as NamedRange, P as PublicServiceItem, S as SUPPORTED_CURRENCIES, w as Sale, x as SaleCursorPage, y as SaleFilters, z as SaleInput, E as SaleItem, F as SaleItemInput, H as SaleKeysetSortField, I as SaleListPage, J as SaleListQuery, K as SaleListQueryV2, L as SaleService, M as SaleServiceInput, O as SaleSortField, Q as SaleSortOrder, R as SaleSummary, U as SaleSummaryPrevious, V as SaleSummaryQuery, W as SaleSummaryQueryV2, X as SaleSummaryV2, Y as SaleUpdateInput, Z as SalesBusinessClient, _ as SalesCategoryBreakdown, $ as SalesClient, a0 as SalesClientConfig, a1 as SalesCustomersClient, a2 as SalesServiceBreakdown, a3 as SalesTransportConfig, a4 as SalesTrendPoint, a5 as SummaryCurrencyDelta, a6 as SummaryDeltas, a7 as SummaryWindow, a8 as SupportedCurrency, a9 as TRACKING_RANGES, aa as TrackingOverviewRange, ac as createSalesClient, ad as fetchServices, ae as formatDateInTz, af as formatMoney, ag as fromMinor, aj as saleCreateSchema, ak as saleItemSchema, al as saleServiceSchema, am as saleUpdateSchema, an as salesRequest, ap as toMinor } from './sales-CBQJ2SBT.js';
|
|
2
2
|
import 'zod';
|
|
3
3
|
import 'libphonenumber-js';
|
package/dist/sales.js
CHANGED
|
@@ -234,7 +234,7 @@ var SDK_PACKAGE_HEADER = "X-Aranova-Sdk-Package";
|
|
|
234
234
|
var SDK_SURFACE_HEADER = "X-Aranova-Sdk-Surface";
|
|
235
235
|
var SDK_ENVIRONMENT_HEADER = "X-Aranova-Sdk-Environment";
|
|
236
236
|
|
|
237
|
-
// ../tracking-core/src/resources/
|
|
237
|
+
// ../tracking-core/src/resources/http/errors.ts
|
|
238
238
|
var AranovaApiError = class extends Error {
|
|
239
239
|
constructor(message, options) {
|
|
240
240
|
super(message);
|
|
@@ -245,7 +245,7 @@ var AranovaApiError = class extends Error {
|
|
|
245
245
|
}
|
|
246
246
|
};
|
|
247
247
|
|
|
248
|
-
// ../tracking-core/src/resources/
|
|
248
|
+
// ../tracking-core/src/resources/http/request.ts
|
|
249
249
|
function identityHeaders(config) {
|
|
250
250
|
const headers = { [API_KEY_HEADER]: config.apiKey };
|
|
251
251
|
if (config.sdkVersion) headers[SDK_VERSION_HEADER] = config.sdkVersion;
|
|
@@ -257,8 +257,8 @@ function identityHeaders(config) {
|
|
|
257
257
|
function joinUrl(endpoint, path) {
|
|
258
258
|
return `${endpoint.replace(/\/$/, "")}${path}`;
|
|
259
259
|
}
|
|
260
|
-
async function
|
|
261
|
-
const headers = identityHeaders(config);
|
|
260
|
+
async function apiRequest(config, method, path, body, extraHeaders) {
|
|
261
|
+
const headers = { ...identityHeaders(config), ...extraHeaders };
|
|
262
262
|
if (body !== void 0) headers["Content-Type"] = "application/json";
|
|
263
263
|
const response = await fetch(joinUrl(config.endpoint, path), {
|
|
264
264
|
method,
|
|
@@ -287,6 +287,24 @@ async function salesRequest(config, method, path, body) {
|
|
|
287
287
|
return await response.json();
|
|
288
288
|
}
|
|
289
289
|
|
|
290
|
+
// ../tracking-core/src/resources/sales/transport.ts
|
|
291
|
+
var salesRequest = apiRequest;
|
|
292
|
+
|
|
293
|
+
// ../tracking-core/src/resources/intl/date.ts
|
|
294
|
+
function formatDateInTz(iso, timeZone, opts, locale) {
|
|
295
|
+
const date = new Date(iso);
|
|
296
|
+
if (Number.isNaN(date.getTime())) return iso;
|
|
297
|
+
return new Intl.DateTimeFormat(locale, {
|
|
298
|
+
year: "numeric",
|
|
299
|
+
month: "short",
|
|
300
|
+
day: "2-digit",
|
|
301
|
+
hour: "2-digit",
|
|
302
|
+
minute: "2-digit",
|
|
303
|
+
...opts,
|
|
304
|
+
timeZone
|
|
305
|
+
}).format(date);
|
|
306
|
+
}
|
|
307
|
+
|
|
290
308
|
// ../tracking-core/src/resources/sales/money.ts
|
|
291
309
|
var MINOR_UNIT_EXPONENT = {
|
|
292
310
|
USD: 2,
|
|
@@ -306,19 +324,6 @@ function formatMoney(cents, currency, locale) {
|
|
|
306
324
|
fromMinor(cents, currency)
|
|
307
325
|
);
|
|
308
326
|
}
|
|
309
|
-
function formatDateInTz(iso, timeZone, opts, locale) {
|
|
310
|
-
const date = new Date(iso);
|
|
311
|
-
if (Number.isNaN(date.getTime())) return iso;
|
|
312
|
-
return new Intl.DateTimeFormat(locale, {
|
|
313
|
-
year: "numeric",
|
|
314
|
-
month: "short",
|
|
315
|
-
day: "2-digit",
|
|
316
|
-
hour: "2-digit",
|
|
317
|
-
minute: "2-digit",
|
|
318
|
-
...opts,
|
|
319
|
-
timeZone
|
|
320
|
-
}).format(date);
|
|
321
|
-
}
|
|
322
327
|
|
|
323
328
|
// ../tracking-core/src/resources/sales/client.ts
|
|
324
329
|
function fireRecordedConversions(firing, input, recorded, sale, currency) {
|