@ampcode/plugin 0.0.0-20261120001239-g1226ba9 → 0.0.0-20261121001209-g52ff7e1

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.
Files changed (2) hide show
  1. package/index.d.ts +37 -0
  2. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -1690,6 +1690,43 @@ declare module '@ampcode/plugin' {
1690
1690
  * app the user is always present, so the dialog is always shown.
1691
1691
  */
1692
1692
  skipIfUnwatched?: boolean
1693
+
1694
+ /**
1695
+ * Called with details about the answer, such as who answered, before the dialog resolves.
1696
+ * The dialog resolves only after this returns, or after its promise settles when it is
1697
+ * async, so the details are available as soon as the dialog's promise resolves. Use it to
1698
+ * attribute an answer, such as an approval, to the person who gave it: while multiplayer is
1699
+ * active a contributor may answer, who is not the user in `ctx.system.user`. Not called
1700
+ * when the dialog fails.
1701
+ *
1702
+ * @example
1703
+ * ```ts
1704
+ * let approver: string | undefined
1705
+ * const approved = await ctx.ui.confirm({
1706
+ * title: 'Ship this PR?',
1707
+ * requireHuman: true,
1708
+ * onAnswered: ({ responder }) => {
1709
+ * approver = responder?.userID
1710
+ * },
1711
+ * })
1712
+ * ```
1713
+ */
1714
+ onAnswered?: (answer: PluginDialogAnswerMetadata) => void | Promise<void>
1715
+ }
1716
+
1717
+ /** Details about a dialog's answer, passed to {@link PluginDialogOptions.onAnswered}. */
1718
+ export interface PluginDialogAnswerMetadata {
1719
+ /**
1720
+ * Who answered, or undefined when no person did, such as a `skipIfUnwatched` dialog that
1721
+ * nobody was watching, or when this Amp client cannot tell.
1722
+ */
1723
+ responder: PluginDialogResponder | undefined
1724
+ }
1725
+
1726
+ /** The person who answered a dialog. */
1727
+ export interface PluginDialogResponder {
1728
+ /** Amp user ID of the person who answered. */
1729
+ userID: string
1693
1730
  }
1694
1731
 
1695
1732
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ampcode/plugin",
3
- "version": "0.0.0-20261120001239-g1226ba9",
3
+ "version": "0.0.0-20261121001209-g52ff7e1",
4
4
  "description": "Amp Plugin API",
5
5
  "license": "Amp Commercial License",
6
6
  "homepage": "https://ampcode.com/docs/plugin-api",