@pplethai/cli 0.13.0 → 0.14.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pplethai/cli",
3
- "version": "0.13.0",
3
+ "version": "0.14.0",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -104,8 +104,10 @@ Where the token comes from:
104
104
  changing anything there.
105
105
  - **Interactive Notifications**: `sendNotification` takes an optional
106
106
  `interaction` and returns `notificationId`; `closeInteraction` closes it
107
- early. Keep `linkPath` as the fallback. Answers (Notification Responses)
108
- arrive at `notificationResponse` on the default export (`src/index.ts`,
107
+ early. Keep `linkPath` as the fallback. `interaction.liveActivity: true`
108
+ asks for a Live Activity on capable iPhones: urgent questions closing
109
+ within 8 h only, and never rely on it being seen. Answers (Notification
110
+ Responses) arrive at `notificationResponse` on the default export (`src/index.ts`,
109
111
  type in `src/notification-response.ts`): dedupe on `event.id`, pick a winner
110
112
  by `respondedAt` then `id` (answers can come after a close), return `410` to
111
113
  stop answers, do slow work in `ctx.waitUntil`. The responder is
@@ -242,6 +242,17 @@ export interface Interaction {
242
242
  actions: InteractionAction[];
243
243
  /** `false` keeps action buttons off the OS notification. Default `true`. */
244
244
  tray?: boolean;
245
+ /**
246
+ * Asks for a Live Activity on capable iPhones: the buttons stay on the Lock
247
+ * Screen and in the Dynamic Island, with no long press. For urgent questions
248
+ * only. Everyone else gets the ordinary notification, and every recipient
249
+ * still has the question in PPLE Today. PPLE Today refuses it (as
250
+ * `invalid_interaction`) unless `expiresAt` is set and at most 8 h ahead,
251
+ * `tray` is not `false`, and the question shows buttons on the phone: no
252
+ * `radio`, `checkbox` or `required` field, and not a lone `text` field with
253
+ * one action (the reply box) unless that action has `confirm`.
254
+ */
255
+ liveActivity?: boolean;
245
256
  }
246
257
 
247
258
  /**
@@ -107,6 +107,50 @@ describe("interactive notifications: sending", () => {
107
107
  });
108
108
  });
109
109
 
110
+ describe("asking for a Live Activity", () => {
111
+ const urgent: Interaction = {
112
+ ref: "door:7",
113
+ expiresAt: "2026-11-10T16:00:00Z",
114
+ liveActivity: true,
115
+ actions: [
116
+ { id: "open", label: "เปิดประตู", icon: "check", style: "primary" },
117
+ { id: "deny", label: "ไม่เปิด", icon: "x", style: "destructive" },
118
+ ],
119
+ };
120
+
121
+ it("passes liveActivity to today-v2 unchanged", async () => {
122
+ const h = makeHarness(
123
+ {
124
+ notify: () =>
125
+ Response.json(
126
+ { notificationId: "n_2", results: [{ status: "delivered" }] },
127
+ { status: 201 },
128
+ ),
129
+ },
130
+ NOTIFY_ENV,
131
+ );
132
+ const res = await sendWith(h, { interaction: urgent });
133
+ expect(res.status).toBe(200);
134
+ const payload = await h.calls.notify[0]!.json<{ interaction: Record<string, unknown> }>();
135
+ expect(payload.interaction).toEqual(urgent);
136
+ });
137
+
138
+ it("surfaces today-v2's refusal of a Live Activity as invalid_interaction", async () => {
139
+ const h = makeHarness(
140
+ refusal(400, "NOTIFICATION_INVALID_INTERACTION", "interaction.expiresAt: at most 8 h ahead"),
141
+ NOTIFY_ENV,
142
+ );
143
+ const res = await sendWith(h, {
144
+ interaction: { ...urgent, expiresAt: "2026-11-17T00:00:00Z" },
145
+ });
146
+ expect(res.status).toBe(400);
147
+ expect(await res.json()).toEqual({
148
+ error: "invalid_interaction",
149
+ message: "interaction.expiresAt: at most 8 h ahead",
150
+ });
151
+ });
152
+ });
153
+
110
154
  it.each(["NOTIFICATION_INTERACTION_NO_CALLBACK", "INTERACTIVE_NOTIFICATIONS_DISABLED"])(
111
155
  "reports %s as interaction_unavailable",
112
156
  async (code) => {