@simplepush/cli 0.6.0 → 0.8.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/main.mjs +67 -20
- package/dist/main.mjs.map +1 -1
- package/package.json +2 -2
package/dist/main.mjs
CHANGED
|
@@ -14,7 +14,7 @@ import { mkdir, stat, writeFile } from "node:fs/promises";
|
|
|
14
14
|
import { connect, createConnection } from "node:net";
|
|
15
15
|
import path, { basename, extname, join } from "node:path";
|
|
16
16
|
//#region package.json
|
|
17
|
-
var version = "0.
|
|
17
|
+
var version = "0.8.0";
|
|
18
18
|
//#endregion
|
|
19
19
|
//#region src/errors.ts
|
|
20
20
|
/** No CLI session saved — `sp auth login` hasn't been run (or was logged out). */
|
|
@@ -573,6 +573,46 @@ const quietOption = Options.boolean("quiet").pipe(Options.withAlias("q"), Option
|
|
|
573
573
|
/** Shared helper for repeatable validated text options. */
|
|
574
574
|
const mappedText = (name, parse) => Options.text(name).pipe(Options.mapTryCatch(parse, toHelp));
|
|
575
575
|
//#endregion
|
|
576
|
+
//#region src/services/browser.ts
|
|
577
|
+
/** The command line that opens `url` on `platform`. Pure, so it can be tested
|
|
578
|
+
* for every platform from one machine. */
|
|
579
|
+
function browserLaunch(platform, url) {
|
|
580
|
+
switch (platform) {
|
|
581
|
+
case "darwin": return {
|
|
582
|
+
command: "open",
|
|
583
|
+
args: [url],
|
|
584
|
+
windowsVerbatimArguments: false
|
|
585
|
+
};
|
|
586
|
+
case "win32": return {
|
|
587
|
+
command: "cmd",
|
|
588
|
+
args: [
|
|
589
|
+
"/c",
|
|
590
|
+
"start",
|
|
591
|
+
"\"\"",
|
|
592
|
+
url.replace(/&/g, "^&")
|
|
593
|
+
],
|
|
594
|
+
windowsVerbatimArguments: true
|
|
595
|
+
};
|
|
596
|
+
default: return {
|
|
597
|
+
command: "xdg-open",
|
|
598
|
+
args: [url],
|
|
599
|
+
windowsVerbatimArguments: false
|
|
600
|
+
};
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
/** Fire-and-forget. A failure to spawn is swallowed: the caller has already
|
|
604
|
+
* printed the URL, so the user can open it by hand. */
|
|
605
|
+
const openInBrowser = (url) => Effect.sync(() => {
|
|
606
|
+
const launch = browserLaunch(process.platform, url);
|
|
607
|
+
try {
|
|
608
|
+
spawn(launch.command, launch.args, {
|
|
609
|
+
detached: true,
|
|
610
|
+
stdio: "ignore",
|
|
611
|
+
windowsVerbatimArguments: launch.windowsVerbatimArguments
|
|
612
|
+
}).unref();
|
|
613
|
+
} catch {}
|
|
614
|
+
});
|
|
615
|
+
//#endregion
|
|
576
616
|
//#region src/format.ts
|
|
577
617
|
function formatInstant(iso) {
|
|
578
618
|
const d = new Date(iso);
|
|
@@ -661,21 +701,6 @@ const startCallbackServer = Effect.gen(function* () {
|
|
|
661
701
|
awaitCallback: Deferred.await(callback)
|
|
662
702
|
};
|
|
663
703
|
});
|
|
664
|
-
const openInBrowser = (url) => Effect.sync(() => {
|
|
665
|
-
const cmd = process.platform === "darwin" ? "open" : process.platform === "win32" ? "cmd" : "xdg-open";
|
|
666
|
-
const args = process.platform === "win32" ? [
|
|
667
|
-
"/c",
|
|
668
|
-
"start",
|
|
669
|
-
"",
|
|
670
|
-
url
|
|
671
|
-
] : [url];
|
|
672
|
-
try {
|
|
673
|
-
spawn(cmd, args, {
|
|
674
|
-
detached: true,
|
|
675
|
-
stdio: "ignore"
|
|
676
|
-
}).unref();
|
|
677
|
-
} catch {}
|
|
678
|
-
});
|
|
679
704
|
function preferDeviceFlow() {
|
|
680
705
|
if (process.env.SP_AUTH_DEVICE === "1") return true;
|
|
681
706
|
if (process.env.SSH_CONNECTION || process.env.SSH_TTY) return true;
|
|
@@ -2476,7 +2501,7 @@ function formatHit(h) {
|
|
|
2476
2501
|
return [
|
|
2477
2502
|
`${h.ref} [${h.kind}] ${h.createdAt}`,
|
|
2478
2503
|
h.title !== void 0 ? ` ${h.title}` : void 0,
|
|
2479
|
-
h.actor !== void 0 ? ` by: ${h.actor}` : void 0,
|
|
2504
|
+
h.actor !== void 0 ? ` by: ${h.actor.name !== void 0 ? `${h.actor.name} (${h.actor.publicId})` : h.actor.publicId}` : void 0,
|
|
2480
2505
|
h.snippet !== void 0 ? ` ${h.snippet}` : void 0,
|
|
2481
2506
|
h.location !== void 0 ? ` at: ${h.location.latitude},${h.location.longitude}${h.location.distanceMeters !== void 0 ? ` (${Math.round(h.location.distanceMeters)}m away)` : ""}` : void 0
|
|
2482
2507
|
].filter((l) => l !== void 0).join("\n");
|
|
@@ -2529,6 +2554,15 @@ const searchCommand = Command.make("search", {
|
|
|
2529
2554
|
if (res.hits.length === 0 && args.format === "pretty") yield* ctx.out.info("no hits");
|
|
2530
2555
|
}))).pipe(Command.withDescription("Ranked full-text and location search over everything this credential reads, across all time. Words match literally plus stemmed in the org's configured languages; --near/--radius or --within search by place instead of or on top of words."));
|
|
2531
2556
|
//#endregion
|
|
2557
|
+
//#region src/commands/priority-options.ts
|
|
2558
|
+
const priorityOption = Options.integer("priority").pipe(Options.withDescription("How loudly the push interrupts, 1 (minimal: silent, no banner) to 5 (critical: sounds even on a muted phone). Default 3. 4 and 5 get through Do Not Disturb / Focus."), Options.filterMap((n) => n >= 1 && n <= 5 ? Option.some(n) : Option.none(), "--priority must be between 1 and 5"), Options.optional);
|
|
2559
|
+
const criticalVolumeOption = Options.float("critical-volume").pipe(Options.withDescription("Volume of the iOS critical alert sound, greater than 0 and at most 1 (default 1). Only with --priority 5."), Options.filterMap((v) => v > 0 && v <= 1 ? Option.some(v) : Option.none(), "--critical-volume must be greater than 0 and at most 1"), Options.optional);
|
|
2560
|
+
/** The SDK option fields for the two flags; absent flags produce no keys. */
|
|
2561
|
+
const priorityFields = (priority, criticalVolume) => ({
|
|
2562
|
+
...Option.isSome(priority) ? { priority: priority.value } : {},
|
|
2563
|
+
...Option.isSome(criticalVolume) ? { criticalVolume: criticalVolume.value } : {}
|
|
2564
|
+
});
|
|
2565
|
+
//#endregion
|
|
2532
2566
|
//#region src/input-spec.ts
|
|
2533
2567
|
const SETTING_RE = /^[A-Za-z_][A-Za-z0-9_]*=/;
|
|
2534
2568
|
function looksLikeSetting(seg) {
|
|
@@ -2938,6 +2972,8 @@ const notifyCommand = Command.make("notify", {
|
|
|
2938
2972
|
"choice-input": choiceInputOption,
|
|
2939
2973
|
"action-input": actionInputOption,
|
|
2940
2974
|
shared: sharedOption$1,
|
|
2975
|
+
priority: priorityOption,
|
|
2976
|
+
"critical-volume": criticalVolumeOption,
|
|
2941
2977
|
format: formatOption$2,
|
|
2942
2978
|
noEncrypt: noEncryptOption$2,
|
|
2943
2979
|
topic: topicOption$1,
|
|
@@ -2990,7 +3026,8 @@ const notifyCommand = Command.make("notify", {
|
|
|
2990
3026
|
...input !== void 0 ? { input } : {},
|
|
2991
3027
|
...imageUrl !== void 0 ? { image: imageUrl } : {},
|
|
2992
3028
|
...audioUrl !== void 0 ? { audio: audioUrl } : {},
|
|
2993
|
-
...linkUrl !== void 0 ? { link: linkUrl } : {}
|
|
3029
|
+
...linkUrl !== void 0 ? { link: linkUrl } : {},
|
|
3030
|
+
...priorityFields(args.priority, args["critical-volume"])
|
|
2994
3031
|
};
|
|
2995
3032
|
yield* Effect.scoped(Effect.gen(function* () {
|
|
2996
3033
|
const client = yield* acquireOrgClient({
|
|
@@ -3051,7 +3088,8 @@ const notifyCommand = Command.make("notify", {
|
|
|
3051
3088
|
...input !== void 0 ? { input } : {},
|
|
3052
3089
|
...imageUrl !== void 0 ? { image: imageUrl } : {},
|
|
3053
3090
|
...audioUrl !== void 0 ? { audio: audioUrl } : {},
|
|
3054
|
-
...linkUrl !== void 0 ? { link: linkUrl } : {}
|
|
3091
|
+
...linkUrl !== void 0 ? { link: linkUrl } : {},
|
|
3092
|
+
...priorityFields(args.priority, args["critical-volume"])
|
|
3055
3093
|
};
|
|
3056
3094
|
yield* Effect.scoped(Effect.gen(function* () {
|
|
3057
3095
|
const client = yield* acquireClient({
|
|
@@ -3855,6 +3893,8 @@ const taskCommand = Command.make("task", {
|
|
|
3855
3893
|
"org-topic": orgTopicOption,
|
|
3856
3894
|
"no-encrypt": noEncryptOption$1,
|
|
3857
3895
|
markdown: markdownOption$1,
|
|
3896
|
+
priority: priorityOption,
|
|
3897
|
+
"critical-volume": criticalVolumeOption,
|
|
3858
3898
|
shared: sharedOption,
|
|
3859
3899
|
expires: expiresOption,
|
|
3860
3900
|
format: formatOption$1,
|
|
@@ -3901,6 +3941,7 @@ const taskCommand = Command.make("task", {
|
|
|
3901
3941
|
autoCommit: args["auto-commit"],
|
|
3902
3942
|
reply: Option.getOrUndefined(args.reply),
|
|
3903
3943
|
markdown: args.markdown,
|
|
3944
|
+
...priorityFields(args.priority, args["critical-volume"]),
|
|
3904
3945
|
noEncrypt: args["no-encrypt"],
|
|
3905
3946
|
wait: args.wait,
|
|
3906
3947
|
shared: args.shared,
|
|
@@ -3928,6 +3969,7 @@ const taskCommand = Command.make("task", {
|
|
|
3928
3969
|
autoCommit: args["auto-commit"],
|
|
3929
3970
|
...Option.isSome(args.reply) ? { reply: args.reply.value } : {},
|
|
3930
3971
|
...args.markdown ? { contentFormat: "markdown" } : {},
|
|
3972
|
+
...priorityFields(args.priority, args["critical-volume"]),
|
|
3931
3973
|
...expiresAt !== void 0 ? { expiresAt } : {}
|
|
3932
3974
|
};
|
|
3933
3975
|
if (topic === void 0) {
|
|
@@ -4051,6 +4093,8 @@ const sendOrgTask = (params) => Effect.gen(function* () {
|
|
|
4051
4093
|
autoCommit: params.autoCommit,
|
|
4052
4094
|
...params.reply !== void 0 ? { reply: params.reply } : {},
|
|
4053
4095
|
...params.markdown ? { contentFormat: "markdown" } : {},
|
|
4096
|
+
...params.priority !== void 0 ? { priority: params.priority } : {},
|
|
4097
|
+
...params.criticalVolume !== void 0 ? { criticalVolume: params.criticalVolume } : {},
|
|
4054
4098
|
...params.expiresAt !== void 0 ? { expiresAt: params.expiresAt } : {}
|
|
4055
4099
|
};
|
|
4056
4100
|
const orgMasterKeys = vault ? [vault.masterKeyCurrent, ...vault.masterKeyHistory].map((k) => ({
|
|
@@ -4162,6 +4206,8 @@ const subtaskCommand = Command.make("subtask", {
|
|
|
4162
4206
|
format: formatOption,
|
|
4163
4207
|
reply: replyOption,
|
|
4164
4208
|
markdown: markdownOption,
|
|
4209
|
+
priority: priorityOption,
|
|
4210
|
+
"critical-volume": criticalVolumeOption,
|
|
4165
4211
|
"no-encrypt": noEncryptOption,
|
|
4166
4212
|
instance: instanceOption,
|
|
4167
4213
|
topic: topicOption$1,
|
|
@@ -4189,7 +4235,8 @@ const subtaskCommand = Command.make("subtask", {
|
|
|
4189
4235
|
links: [...args.link],
|
|
4190
4236
|
autoCommit: args["auto-commit"],
|
|
4191
4237
|
...Option.isSome(args.reply) ? { reply: args.reply.value } : {},
|
|
4192
|
-
...args.markdown ? { contentFormat: "markdown" } : {}
|
|
4238
|
+
...args.markdown ? { contentFormat: "markdown" } : {},
|
|
4239
|
+
...priorityFields(args.priority, args["critical-volume"])
|
|
4193
4240
|
};
|
|
4194
4241
|
const instances = args.instance.length > 0 ? [...args.instance] : void 0;
|
|
4195
4242
|
const apiToken = Option.getOrUndefined(args["api-token"]);
|