@pplethai/cli 0.13.0 → 0.15.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/README.md +5 -0
- package/dist/bin.js +113 -106
- package/package.json +1 -1
- package/templates/golden-path/CLAUDE.md +4 -2
- package/templates/golden-path/gitignore +3 -0
- package/templates/golden-path/shared/api.ts +11 -0
- package/templates/golden-path/test/interaction.test.ts +44 -0
- package/templates/golden-path/wrangler.jsonc +14 -0
package/package.json
CHANGED
|
@@ -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.
|
|
108
|
-
|
|
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
|
|
@@ -9,6 +9,9 @@ dist/
|
|
|
9
9
|
.cursor/rules/pple-platform.mdc
|
|
10
10
|
.pple/rules.md
|
|
11
11
|
.pple/guidance.json
|
|
12
|
+
.claude/skills/pple-durable-objects/
|
|
13
|
+
.agents/skills/pple-durable-objects/
|
|
14
|
+
.pple/durable-object-guidance.json
|
|
12
15
|
.pple/registry/
|
|
13
16
|
.pple/registry.json
|
|
14
17
|
.pple/registry-check.json
|
|
@@ -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) => {
|
|
@@ -59,6 +59,20 @@
|
|
|
59
59
|
//
|
|
60
60
|
// "triggers": { "crons": ["0 1 * * *"] },
|
|
61
61
|
|
|
62
|
+
// Durable Objects. Export the class from src/index.ts (the Worker's main
|
|
63
|
+
// module). Local `npm run dev` emulates it with no extra setup: this binding
|
|
64
|
+
// and the migration are enough, and nothing is provisioned in the cloud.
|
|
65
|
+
// A deployed app receives the binding only while it holds Durable Object
|
|
66
|
+
// access — ask a Platform Admin in an App Note (บันทึก). New classes are
|
|
67
|
+
// SQLite (`new_sqlite_classes` only). Uncomment both blocks together:
|
|
68
|
+
//
|
|
69
|
+
// "durable_objects": {
|
|
70
|
+
// "bindings": [{ "name": "COUNTER", "class_name": "Counter" }]
|
|
71
|
+
// },
|
|
72
|
+
// "migrations": [
|
|
73
|
+
// { "tag": "v1", "new_sqlite_classes": ["Counter"] }
|
|
74
|
+
// ],
|
|
75
|
+
|
|
62
76
|
"vars": {
|
|
63
77
|
// PPLE ID (identity). The Worker validates bearer tokens against this.
|
|
64
78
|
"SSO_BASE_URL": "https://id.peoplesparty.or.th",
|