@sprigr/apps-app-sdk 0.8.7 → 0.8.8
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.ts +17 -0
- package/dist/index.js +14 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -902,6 +902,15 @@ interface AppApprovalEnvelope {
|
|
|
902
902
|
* retry silently discards the tap. See `approvalHash`.
|
|
903
903
|
*/
|
|
904
904
|
hash?: string;
|
|
905
|
+
/**
|
|
906
|
+
* How many records this ONE call touches, as you count them. Required for a
|
|
907
|
+
* workflow step's standing approval to cover the call on an unattended run
|
|
908
|
+
* (sprigr-team decision 0039): the platform cannot see inside your write,
|
|
909
|
+
* so an envelope with no count gets a person or nothing. The wrappers set
|
|
910
|
+
* it to 1 for a single-target spec; a batch action supplies
|
|
911
|
+
* `ApprovalSpec.count`.
|
|
912
|
+
*/
|
|
913
|
+
count?: number;
|
|
905
914
|
}
|
|
906
915
|
/**
|
|
907
916
|
* Platform-stamped marker telling an app that a human approved this call. The
|
|
@@ -1105,6 +1114,14 @@ interface ApprovalSpec<P = unknown> {
|
|
|
1105
1114
|
* Use `set()` / `seq()` from `approval-hash`. Never include `confirm`.
|
|
1106
1115
|
*/
|
|
1107
1116
|
hash?: (args: ToolArgs) => Array<string | number | undefined | null>;
|
|
1117
|
+
/**
|
|
1118
|
+
* How many records this call touches, for `_approval.count`. Omit for a
|
|
1119
|
+
* single-target tool (the wrapper reports 1 when a `keys` id resolved, and
|
|
1120
|
+
* nothing when none did). A batch action (delete these ids, tag these
|
|
1121
|
+
* products) MUST supply it, or it reports nothing and no standing approval
|
|
1122
|
+
* can ever cover it, which is the safe side but not the useful one.
|
|
1123
|
+
*/
|
|
1124
|
+
count?: (args: ToolArgs) => number;
|
|
1108
1125
|
/** Present only for tools whose write can be (partly) reversed. */
|
|
1109
1126
|
undo?: UndoCaptureSpec<P>;
|
|
1110
1127
|
}
|
package/dist/index.js
CHANGED
|
@@ -614,6 +614,17 @@ function rawIdOf(args, keys) {
|
|
|
614
614
|
}
|
|
615
615
|
return "";
|
|
616
616
|
}
|
|
617
|
+
function countOf(spec, params, rawId) {
|
|
618
|
+
if (spec.count) {
|
|
619
|
+
try {
|
|
620
|
+
const n = spec.count(params);
|
|
621
|
+
return Number.isFinite(n) && n >= 0 ? Math.floor(n) : void 0;
|
|
622
|
+
} catch {
|
|
623
|
+
return void 0;
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
return rawId ? 1 : void 0;
|
|
627
|
+
}
|
|
617
628
|
function isOk(result) {
|
|
618
629
|
return !!result && typeof result === "object" && result.ok !== false;
|
|
619
630
|
}
|
|
@@ -635,11 +646,13 @@ async function askPass(name, spec, params, env, opts, hashPrefix) {
|
|
|
635
646
|
const pinned = await pin(opts, env, connection);
|
|
636
647
|
const target = rawId && opts.describeTarget ? await safeLabel(opts.describeTarget, pinned, rawId, name) : rawId || "(unknown id)";
|
|
637
648
|
const extra = spec.hash ? spec.hash(params) : [];
|
|
649
|
+
const count = countOf(spec, params, rawId);
|
|
638
650
|
return {
|
|
639
651
|
ok: false,
|
|
640
652
|
_approval: {
|
|
641
653
|
...spec.describe(target, params, connection),
|
|
642
|
-
hash: approvalHash(...hashPrefix, rawId, connection, ...extra)
|
|
654
|
+
hash: approvalHash(...hashPrefix, rawId, connection, ...extra),
|
|
655
|
+
...count !== void 0 ? { count } : {}
|
|
643
656
|
}
|
|
644
657
|
};
|
|
645
658
|
}
|