@palettelab/cli 0.3.56 → 0.3.57
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 +31 -24
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -398,28 +398,10 @@ package dependency policy, and backend package size.
|
|
|
398
398
|
|
|
399
399
|
## OS Notifications
|
|
400
400
|
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
import { notifications } from "@palettelab/sdk"
|
|
406
|
-
// or: palette.notifications.push(...)
|
|
407
|
-
|
|
408
|
-
await notifications.push({
|
|
409
|
-
title: "Export complete",
|
|
410
|
-
body: "Your report is ready to download.",
|
|
411
|
-
severity: "success", // "info" | "success" | "warning" | "error"
|
|
412
|
-
targetApp: "reports-app", // app icon that owns the unread badge
|
|
413
|
-
route: "/exports/123", // opened inside your app on click
|
|
414
|
-
})
|
|
415
|
-
```
|
|
416
|
-
|
|
417
|
-
The notification shows as a live toast plus a notification-center entry;
|
|
418
|
-
clicking it opens/focuses the target app at the resolved route. Use the SDK
|
|
419
|
-
helper rather than hand-building platform notification API calls.
|
|
420
|
-
|
|
421
|
-
Python plugin backends can push too, via `ctx.notifications` in the CLI-bundled
|
|
422
|
-
backend SDK:
|
|
401
|
+
Backend apps created or served by the CLI should use the Python helper from the
|
|
402
|
+
CLI-bundled backend SDK. This is the helper to use for cross-user flows such as
|
|
403
|
+
leave approvals, review requests, task assignment, and same-organisation
|
|
404
|
+
recipient targeting:
|
|
423
405
|
|
|
424
406
|
```python
|
|
425
407
|
from palette_sdk import PluginContext, get_plugin_context, require_permission
|
|
@@ -432,14 +414,39 @@ async def start_export(ctx: PluginContext = Depends(get_plugin_context)):
|
|
|
432
414
|
body="A leave request needs approval.",
|
|
433
415
|
to=ctx.notifications.user(approver_user_id),
|
|
434
416
|
target_app="hierarchy-app",
|
|
417
|
+
route=f"/approvals/{request_id}",
|
|
418
|
+
severity="warning", # "info" | "success" | "warning" | "error"
|
|
419
|
+
data={"request_id": request_id},
|
|
435
420
|
)
|
|
436
421
|
```
|
|
437
422
|
|
|
438
423
|
By default the backend helper notifies the user making the current request;
|
|
439
424
|
pass `to=ctx.notifications.user(...)`, `.email(...)`, `.member(...)`,
|
|
440
425
|
`.role(...)`, `.team(...)`, or `.mentions_from(...)` to notify other same-org
|
|
441
|
-
members. `target_app` controls the app icon badge and default click target.
|
|
442
|
-
`
|
|
426
|
+
members. `target_app` controls the app icon badge and default click target.
|
|
427
|
+
`route` is optional and should only be set when the target app has a matching
|
|
428
|
+
deep-link page. See `docs/python-backend-sdk.md` ("OS Notifications From
|
|
429
|
+
Python") for details.
|
|
430
|
+
|
|
431
|
+
Frontend apps can also push notifications for the current signed-in user with
|
|
432
|
+
`@palettelab/sdk@0.1.27+`. This TypeScript helper is frontend-only and is not
|
|
433
|
+
the Python backend helper:
|
|
434
|
+
|
|
435
|
+
```ts
|
|
436
|
+
import { notifications } from "@palettelab/sdk"
|
|
437
|
+
// or: palette.notifications.push(...)
|
|
438
|
+
|
|
439
|
+
await notifications.push({
|
|
440
|
+
title: "Export complete",
|
|
441
|
+
body: "Your report is ready to download.",
|
|
442
|
+
severity: "success", // "info" | "success" | "warning" | "error"
|
|
443
|
+
targetApp: "reports-app", // app icon that owns the unread badge
|
|
444
|
+
route: "/exports/123", // opened inside your app on click
|
|
445
|
+
})
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
Both helpers create a live toast plus a notification-center entry. Use these
|
|
449
|
+
helpers rather than hand-building platform notification API calls.
|
|
443
450
|
|
|
444
451
|
During `pltt dev`, frontend pushes call the platform backend directly
|
|
445
452
|
(`NEXT_PUBLIC_API_URL`, default `http://localhost:8000`) in the user's session,
|