@flaredlink/cli 0.2.0 → 0.3.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/flared.js +10 -4
- package/package.json +1 -1
package/dist/flared.js
CHANGED
|
@@ -20,7 +20,7 @@ function isLinkAnalytics(value) {
|
|
|
20
20
|
if (typeof value !== "object" || value === null)
|
|
21
21
|
return false;
|
|
22
22
|
const analytics = value;
|
|
23
|
-
return typeof analytics.linkId === "string" && typeof analytics.from === "string" && typeof analytics.to === "string" && isCount(analytics.total) && isRows(analytics.days, "day") && isRows(analytics.countries, "value") && isRows(analytics.devices, "value") && isRows(analytics.referrers, "value") && typeof analytics.asOf === "string";
|
|
23
|
+
return typeof analytics.linkId === "string" && typeof analytics.from === "string" && typeof analytics.to === "string" && isCount(analytics.total) && isRows(analytics.days, "day") && isRows(analytics.countries, "value") && isRows(analytics.devices, "value") && isRows(analytics.referrers, "value") && (analytics.browsers === undefined || isRows(analytics.browsers, "value")) && (analytics.operatingSystems === undefined || isRows(analytics.operatingSystems, "value")) && typeof analytics.asOf === "string";
|
|
24
24
|
}
|
|
25
25
|
function isUsage(value) {
|
|
26
26
|
if (typeof value !== "object" || value === null)
|
|
@@ -42,6 +42,8 @@ function isUsageWarning(value) {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
// ../contracts/src/links.ts
|
|
45
|
+
var recentClickDays = 30;
|
|
46
|
+
|
|
45
47
|
class LinkInputError extends Error {
|
|
46
48
|
field;
|
|
47
49
|
constructor(field, message) {
|
|
@@ -60,8 +62,10 @@ function isLink(value) {
|
|
|
60
62
|
function isListedLink(value) {
|
|
61
63
|
if (!isRecord(value) || !isLink(value))
|
|
62
64
|
return false;
|
|
65
|
+
const isCount2 = (item) => Number.isSafeInteger(item) && item >= 0;
|
|
63
66
|
const clicks = value.clicksLast30Days;
|
|
64
|
-
|
|
67
|
+
const daily = value.dailyClicksLast30Days;
|
|
68
|
+
return (clicks === null || isCount2(clicks)) && (daily === undefined || daily === null || Array.isArray(daily) && daily.length === recentClickDays && daily.every(isCount2));
|
|
65
69
|
}
|
|
66
70
|
function isLinkPage(value) {
|
|
67
71
|
return isRecord(value) && Array.isArray(value.links) && value.links.every(isListedLink) && (value.nextCursor === null || typeof value.nextCursor === "string");
|
|
@@ -158,7 +162,7 @@ function isErrorCode(value) {
|
|
|
158
162
|
|
|
159
163
|
// ../contracts/src/export.ts
|
|
160
164
|
var exportFormat = "flared.export/1";
|
|
161
|
-
var exportDimensions = ["country", "device", "referrer"];
|
|
165
|
+
var exportDimensions = ["country", "device", "referrer", "browser", "os"];
|
|
162
166
|
function isRecord3(value) {
|
|
163
167
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
164
168
|
}
|
|
@@ -1020,6 +1024,8 @@ function analyticsReport(link, analytics) {
|
|
|
1020
1024
|
["Countries", top(analytics.countries)],
|
|
1021
1025
|
["Referrers", top(analytics.referrers)],
|
|
1022
1026
|
["Devices", top(analytics.devices)],
|
|
1027
|
+
...analytics.browsers ? [["Browsers", top(analytics.browsers)]] : [],
|
|
1028
|
+
...analytics.operatingSystems ? [["Systems", top(analytics.operatingSystems)]] : [],
|
|
1023
1029
|
["As of", utc(analytics.asOf)]
|
|
1024
1030
|
])
|
|
1025
1031
|
].join(`
|
|
@@ -1095,7 +1101,7 @@ function domainDetails(domain) {
|
|
|
1095
1101
|
}
|
|
1096
1102
|
|
|
1097
1103
|
// src/version.ts
|
|
1098
|
-
var cliVersion = "0.
|
|
1104
|
+
var cliVersion = "0.3.0";
|
|
1099
1105
|
|
|
1100
1106
|
// src/cli.ts
|
|
1101
1107
|
var optionTypes = {
|