@terreno/announcements 57.4.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.
Files changed (46) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +50 -0
  3. package/biome.jsonc +20 -0
  4. package/bunfig.toml +2 -0
  5. package/dist/announcementsApp.d.ts +9 -0
  6. package/dist/announcementsApp.js +820 -0
  7. package/dist/help.d.ts +30 -0
  8. package/dist/help.js +72 -0
  9. package/dist/helpRoutes.d.ts +8 -0
  10. package/dist/helpRoutes.js +233 -0
  11. package/dist/index.d.ts +9 -0
  12. package/dist/index.js +34 -0
  13. package/dist/models/announcement.d.ts +3 -0
  14. package/dist/models/announcement.js +214 -0
  15. package/dist/models/announcementAcknowledgement.d.ts +2 -0
  16. package/dist/models/announcementAcknowledgement.js +41 -0
  17. package/dist/models/announcementClickEvent.d.ts +3 -0
  18. package/dist/models/announcementClickEvent.js +56 -0
  19. package/dist/models/announcementImpression.d.ts +3 -0
  20. package/dist/models/announcementImpression.js +50 -0
  21. package/dist/overview.d.ts +14 -0
  22. package/dist/overview.js +310 -0
  23. package/dist/pending.d.ts +64 -0
  24. package/dist/pending.js +242 -0
  25. package/dist/types.d.ts +135 -0
  26. package/dist/types.js +2 -0
  27. package/package.json +57 -0
  28. package/src/announcementsApp.ts +722 -0
  29. package/src/help.ts +98 -0
  30. package/src/helpRoutes.ts +160 -0
  31. package/src/index.ts +45 -0
  32. package/src/models/announcement.ts +189 -0
  33. package/src/models/announcementAcknowledgement.ts +50 -0
  34. package/src/models/announcementClickEvent.ts +68 -0
  35. package/src/models/announcementImpression.ts +62 -0
  36. package/src/overview.ts +228 -0
  37. package/src/pending.ts +286 -0
  38. package/src/tests/announcementsApp.test.ts +844 -0
  39. package/src/tests/bunSetup.ts +9 -0
  40. package/src/tests/help.test.ts +29 -0
  41. package/src/tests/helpRoutes.test.ts +291 -0
  42. package/src/tests/index.test.ts +57 -0
  43. package/src/tests/overview.test.ts +351 -0
  44. package/src/tests/pending.test.ts +262 -0
  45. package/src/types.ts +157 -0
  46. package/tsconfig.json +33 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Flourish Health, Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,50 @@
1
+ # @terreno/announcements
2
+
3
+ In-app product update announcements for Terreno backends.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ bun add @terreno/announcements
9
+ ```
10
+
11
+ Peer dependency: `mongoose ^8.0.0 || ^9.0.0`. `@terreno/api` is required at runtime.
12
+
13
+ ## Quick start
14
+
15
+ ```typescript
16
+ import {AnnouncementsApp} from "@terreno/announcements";
17
+ import {TerrenoApp} from "@terreno/api";
18
+
19
+ new TerrenoApp({userModel: User})
20
+ .register(
21
+ new AnnouncementsApp({
22
+ defaultAcknowledgementPolicy: "dismiss-only",
23
+ help: {enabled: true},
24
+ isStaff: (user) => user.admin === true,
25
+ matchAudience: (user, announcement) => true,
26
+ })
27
+ )
28
+ .start();
29
+ ```
30
+
31
+ Wrap authenticated app content with `AnnouncementNavigator` from `@terreno/ui` on the frontend.
32
+
33
+ ## What's included
34
+
35
+ - `AnnouncementsApp` — user routes (`/pending`, `/feed`, acknowledge, impression, click) plus admin CRUD
36
+ - Optional help API for MCP and agent search (`/announcements/help/*`)
37
+ - First-class `audienceType` (`staff` | `patient` | `all`) composed via exported `matchAudienceByType` and optional `isStaff`
38
+ - Custom segments via `matchAudience` and opaque `audience` JSON on each announcement
39
+ - Per-announcement `acknowledgementPolicy` with consumer `defaultAcknowledgementPolicy`
40
+ - Platform targeting (`ios`, `android`, `web`) with user-agent fallback when `platform` is omitted
41
+
42
+ ## Documentation
43
+
44
+ - Reference: [docs/reference/announcements.md](https://github.com/FlourishHealth/terreno/blob/master/docs/reference/announcements.md)
45
+ - How-to: [docs/how-to/product-announcements.md](https://github.com/FlourishHealth/terreno/blob/master/docs/how-to/product-announcements.md)
46
+ - Implementation plan: [docs/implementationPlans/announcements.md](https://github.com/FlourishHealth/terreno/blob/master/docs/implementationPlans/announcements.md)
47
+
48
+ ## License and Contributing
49
+
50
+ Licensed under the [MIT License](https://github.com/FlourishHealth/terreno/blob/master/LICENSE). See [CONTRIBUTING.md](https://github.com/FlourishHealth/terreno/blob/master/CONTRIBUTING.md) for contribution guidelines.
package/biome.jsonc ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
3
+ "extends": ["../biome.jsonc"],
4
+ "files": {
5
+ "includes": [
6
+ "package.json",
7
+ "src/**/*.ts",
8
+ "src/**/*.tsx",
9
+ "!!**/node_modules",
10
+ "!!node_modules",
11
+ "!!**/dist",
12
+ "!!dist",
13
+ "!!**/build",
14
+ "!!build",
15
+ "!!**/coverage",
16
+ "!!coverage"
17
+ ]
18
+ },
19
+ "root": true
20
+ }
package/bunfig.toml ADDED
@@ -0,0 +1,2 @@
1
+ [test]
2
+ preload = ["./src/tests/bunSetup.ts"]
@@ -0,0 +1,9 @@
1
+ import { type AdminContribution, type TerrenoPlugin } from "@terreno/api";
2
+ import { type Application } from "express";
3
+ import type { AnnouncementsOptions } from "./types";
4
+ export declare class AnnouncementsApp implements TerrenoPlugin {
5
+ private options;
6
+ constructor(options?: AnnouncementsOptions);
7
+ adminContribution(): AdminContribution;
8
+ register(app: Application, openApi?: unknown): void;
9
+ }