activitysmith-cli 1.22.0 → 1.23.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/package.json +1 -1
- package/src/cli.js +46 -23
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "activitysmith-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.23.0",
|
|
4
4
|
"description": "Command-line interface for ActivitySmith. Send Push Notifications, start, update, and end Live Activities, and set App Icon Badge Counts from your terminal.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"activitysmith",
|
package/src/cli.js
CHANGED
|
@@ -143,6 +143,19 @@ const LIVE_ACTIVITY_CHANGE_SOUND_HELP = `${SOUND_HELP}. Silent by default; iOS p
|
|
|
143
143
|
|
|
144
144
|
const withSound = (request, sound) => (sound === undefined ? request : { ...request, sound });
|
|
145
145
|
|
|
146
|
+
const parseRelevanceScoreOption = (value) => {
|
|
147
|
+
const parsed = typeof value === "string" && value.trim() !== "" ? Number(value) : Number.NaN;
|
|
148
|
+
if (!Number.isFinite(parsed) || parsed < 0 || parsed > 100) {
|
|
149
|
+
throw new InvalidArgumentError("relevance-score must be a number from 0 to 100");
|
|
150
|
+
}
|
|
151
|
+
return parsed;
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
const RELEVANCE_SCORE_HELP = "Order when several Live Activities run: 0 to 100, higher shows first";
|
|
155
|
+
|
|
156
|
+
const withRelevanceScore = (request, relevanceScore) =>
|
|
157
|
+
relevanceScore === undefined ? request : { ...request, relevance_score: relevanceScore };
|
|
158
|
+
|
|
146
159
|
const parseMetricValueArgument = (value) => {
|
|
147
160
|
if (typeof value !== "string") {
|
|
148
161
|
throw new InvalidArgumentError("value must be a string or number");
|
|
@@ -1637,6 +1650,7 @@ addLiveActivityActionOptions(addContentStateOptions(
|
|
|
1637
1650
|
`${SOUND_HELP}. A new stream defaults to your Live Activities sound; updates are silent by default, and iOS plays an update sound only while the screen is on`,
|
|
1638
1651
|
parseSoundOption
|
|
1639
1652
|
)
|
|
1653
|
+
.option("--relevance-score <number>", RELEVANCE_SCORE_HELP, parseRelevanceScoreOption)
|
|
1640
1654
|
.option("--metadata <json>", "Metadata JSON object shown in ActivitySmith details")
|
|
1641
1655
|
.option("--metadata-file <path>", "Path to a Metadata JSON object file")
|
|
1642
1656
|
.action(async (streamKey, options) => {
|
|
@@ -1654,20 +1668,23 @@ addLiveActivityActionOptions(addContentStateOptions(
|
|
|
1654
1668
|
|
|
1655
1669
|
const response = await client.liveActivities.stream(
|
|
1656
1670
|
streamKey,
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1671
|
+
withRelevanceScore(
|
|
1672
|
+
withSound(
|
|
1673
|
+
withTags(
|
|
1674
|
+
withTargetChannels(
|
|
1675
|
+
toApiLiveActivityStreamRequest(
|
|
1676
|
+
contentState,
|
|
1677
|
+
action,
|
|
1678
|
+
secondaryAction
|
|
1679
|
+
),
|
|
1680
|
+
options.channels
|
|
1664
1681
|
),
|
|
1665
|
-
options.
|
|
1682
|
+
options.clearTags ? [] : options.tags,
|
|
1683
|
+
await loadMetadata(options)
|
|
1666
1684
|
),
|
|
1667
|
-
options.
|
|
1668
|
-
await loadMetadata(options)
|
|
1685
|
+
options.sound
|
|
1669
1686
|
),
|
|
1670
|
-
options.
|
|
1687
|
+
options.relevanceScore
|
|
1671
1688
|
)
|
|
1672
1689
|
);
|
|
1673
1690
|
|
|
@@ -1704,6 +1721,7 @@ addLiveActivityActionOptions(addContentStateOptions(
|
|
|
1704
1721
|
`${SOUND_HELP} (defaults to your Live Activities sound)`,
|
|
1705
1722
|
parseSoundOption
|
|
1706
1723
|
)
|
|
1724
|
+
.option("--relevance-score <number>", RELEVANCE_SCORE_HELP, parseRelevanceScoreOption)
|
|
1707
1725
|
.option("--metadata <json>", "Metadata JSON object shown in ActivitySmith details")
|
|
1708
1726
|
.option("--metadata-file <path>", "Path to a Metadata JSON object file")
|
|
1709
1727
|
.action(async (options) => {
|
|
@@ -1717,20 +1735,23 @@ addLiveActivityActionOptions(addContentStateOptions(
|
|
|
1717
1735
|
const secondaryAction = await loadLiveActivitySecondaryAction(options);
|
|
1718
1736
|
|
|
1719
1737
|
const response = await client.liveActivities.startLiveActivity({
|
|
1720
|
-
liveActivityStartRequest:
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1738
|
+
liveActivityStartRequest: withRelevanceScore(
|
|
1739
|
+
withSound(
|
|
1740
|
+
withTags(
|
|
1741
|
+
withTargetChannels(
|
|
1742
|
+
toApiLiveActivityStartRequest(
|
|
1743
|
+
contentState,
|
|
1744
|
+
action,
|
|
1745
|
+
secondaryAction
|
|
1746
|
+
),
|
|
1747
|
+
options.channels
|
|
1727
1748
|
),
|
|
1728
|
-
options.
|
|
1749
|
+
options.tags,
|
|
1750
|
+
await loadMetadata(options)
|
|
1729
1751
|
),
|
|
1730
|
-
options.
|
|
1731
|
-
await loadMetadata(options)
|
|
1752
|
+
options.sound
|
|
1732
1753
|
),
|
|
1733
|
-
options.
|
|
1754
|
+
options.relevanceScore
|
|
1734
1755
|
),
|
|
1735
1756
|
});
|
|
1736
1757
|
|
|
@@ -1753,6 +1774,7 @@ addLiveActivityActionOptions(addContentStateOptions(
|
|
|
1753
1774
|
.option("--tags <tags>", "Replace Tags for this Live Activity (repeatable)", parseTagsOption)
|
|
1754
1775
|
.option("--clear-tags", "Remove all Tags from this Live Activity")
|
|
1755
1776
|
.option("--sound <name>", LIVE_ACTIVITY_CHANGE_SOUND_HELP, parseSoundOption)
|
|
1777
|
+
.option("--relevance-score <number>", RELEVANCE_SCORE_HELP, parseRelevanceScoreOption)
|
|
1756
1778
|
.option("--metadata <json>", "Metadata JSON object shown in ActivitySmith details")
|
|
1757
1779
|
.option("--metadata-file <path>", "Path to a Metadata JSON object file")
|
|
1758
1780
|
.action(async (options) => {
|
|
@@ -1769,12 +1791,13 @@ addLiveActivityActionOptions(addContentStateOptions(
|
|
|
1769
1791
|
const secondaryAction = await loadLiveActivitySecondaryAction(options);
|
|
1770
1792
|
|
|
1771
1793
|
const response = await client.liveActivities.updateLiveActivity({
|
|
1772
|
-
liveActivityUpdateRequest: withSound(withTags(toApiLiveActivityUpdateRequest(
|
|
1794
|
+
liveActivityUpdateRequest: withRelevanceScore(withSound(withTags(toApiLiveActivityUpdateRequest(
|
|
1773
1795
|
options.activityId,
|
|
1774
1796
|
contentState,
|
|
1775
1797
|
action,
|
|
1776
1798
|
secondaryAction
|
|
1777
1799
|
), options.clearTags ? [] : options.tags, await loadMetadata(options)), options.sound),
|
|
1800
|
+
options.relevanceScore),
|
|
1778
1801
|
});
|
|
1779
1802
|
|
|
1780
1803
|
outputResult(response, globalOptions, [
|