@endora-commerce/mod-admin-notifications 0.0.0-stage → 0.100.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 (43) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +49 -2
  3. package/dist/backend/entities/admin-notification-read.entity.d.ts +15 -0
  4. package/dist/backend/entities/admin-notification-read.entity.d.ts.map +1 -0
  5. package/dist/backend/entities/admin-notification-read.entity.js +42 -0
  6. package/dist/backend/entities/admin-notification-read.entity.js.map +1 -0
  7. package/dist/backend/entities/admin-notification.entity.d.ts +31 -0
  8. package/dist/backend/entities/admin-notification.entity.d.ts.map +1 -0
  9. package/dist/backend/entities/admin-notification.entity.js +95 -0
  10. package/dist/backend/entities/admin-notification.entity.js.map +1 -0
  11. package/dist/backend/index.d.ts +25 -0
  12. package/dist/backend/index.d.ts.map +1 -0
  13. package/dist/backend/index.js +70 -0
  14. package/dist/backend/index.js.map +1 -0
  15. package/dist/backend/plugin.d.ts +26 -0
  16. package/dist/backend/plugin.d.ts.map +1 -0
  17. package/dist/backend/plugin.js +17 -0
  18. package/dist/backend/plugin.js.map +1 -0
  19. package/dist/backend/routes.admin.d.ts +16 -0
  20. package/dist/backend/routes.admin.d.ts.map +1 -0
  21. package/dist/backend/routes.admin.js +78 -0
  22. package/dist/backend/routes.admin.js.map +1 -0
  23. package/dist/backend/services/admin-notification-port.d.ts +17 -0
  24. package/dist/backend/services/admin-notification-port.d.ts.map +1 -0
  25. package/dist/backend/services/admin-notification-port.js +33 -0
  26. package/dist/backend/services/admin-notification-port.js.map +1 -0
  27. package/dist/backend/services/admin-notification-service.d.ts +78 -0
  28. package/dist/backend/services/admin-notification-service.d.ts.map +1 -0
  29. package/dist/backend/services/admin-notification-service.js +284 -0
  30. package/dist/backend/services/admin-notification-service.js.map +1 -0
  31. package/dist/manifest.d.ts +171 -0
  32. package/dist/manifest.d.ts.map +1 -0
  33. package/dist/manifest.js +46 -0
  34. package/dist/manifest.js.map +1 -0
  35. package/dist/migrations/20260611T140350_admin_notifications_init.d.ts +19 -0
  36. package/dist/migrations/20260611T140350_admin_notifications_init.d.ts.map +1 -0
  37. package/dist/migrations/20260611T140350_admin_notifications_init.js +82 -0
  38. package/dist/migrations/20260611T140350_admin_notifications_init.js.map +1 -0
  39. package/dist/migrations/index.d.ts +27 -0
  40. package/dist/migrations/index.d.ts.map +1 -0
  41. package/dist/migrations/index.js +29 -0
  42. package/dist/migrations/index.js.map +1 -0
  43. package/package.json +63 -3
@@ -0,0 +1,82 @@
1
+ import { Migration } from '@mikro-orm/migrations';
2
+ /**
3
+ * Admin notifications — minimal "bell" surface introduced by feature 026.
4
+ *
5
+ * One row per notification. `audience='all_admins'` rows are visible to
6
+ * every admin (the read state is tracked per-admin in a future iteration
7
+ * via `admin_notification_reads`; for the first iteration we keep `read_at`
8
+ * on the row itself for `audience='admin_user'` rows only, and rely on the
9
+ * `mark-all-read` endpoint stamping a per-admin "last seen" cursor —
10
+ * implemented in code, not in this schema).
11
+ *
12
+ * Unread cap is enforced by application code (`pruneStale()`), not by the
13
+ * schema.
14
+ */
15
+ export class Migration20260611T140350AdminNotificationsInit extends Migration {
16
+ async up() {
17
+ this.addSql(`
18
+ create table "admin_notifications" (
19
+ "id" uuid not null,
20
+ "audience" varchar(16) not null,
21
+ "target_admin_user_id" uuid null,
22
+ "kind" varchar(64) not null,
23
+ "subject_type" varchar(64) null,
24
+ "subject_id" uuid null,
25
+ "title" varchar(255) not null,
26
+ "body" text null,
27
+ "link_path" varchar(255) null,
28
+ "created_at" timestamptz not null default now(),
29
+ "read_at" timestamptz null,
30
+ "archived_at" timestamptz null,
31
+ constraint "admin_notifications_pkey" primary key ("id"),
32
+ constraint "admin_notifications_audience_check"
33
+ check ("audience" in ('all_admins', 'admin_user')),
34
+ constraint "admin_notifications_target_consistency_check"
35
+ check (
36
+ ("audience" = 'all_admins' and "target_admin_user_id" is null)
37
+ or ("audience" = 'admin_user' and "target_admin_user_id" is not null)
38
+ ),
39
+ constraint "admin_notifications_target_admin_user_fk"
40
+ foreign key ("target_admin_user_id") references "admin_users" ("id") on delete cascade
41
+ );
42
+ `);
43
+ // Feed query: most-recent first, filtered by audience + (optionally)
44
+ // target admin.
45
+ this.addSql(`
46
+ create index "admin_notifications_audience_idx"
47
+ on "admin_notifications" ("audience", "target_admin_user_id", "created_at" desc);
48
+ `);
49
+ // Partial index for the unread-count fast path.
50
+ this.addSql(`
51
+ create index "admin_notifications_unread_idx"
52
+ on "admin_notifications" ("audience", "target_admin_user_id")
53
+ where "read_at" is null and "archived_at" is null;
54
+ `);
55
+ // Per-admin read cursor for `audience='all_admins'` rows.
56
+ // (Each admin marks their own copy of a broadcast notification as read.)
57
+ this.addSql(`
58
+ create table "admin_notification_reads" (
59
+ "notification_id" uuid not null,
60
+ "admin_user_id" uuid not null,
61
+ "read_at" timestamptz not null default now(),
62
+ constraint "admin_notification_reads_pkey"
63
+ primary key ("notification_id", "admin_user_id"),
64
+ constraint "admin_notification_reads_notification_fk"
65
+ foreign key ("notification_id") references "admin_notifications" ("id") on delete cascade,
66
+ constraint "admin_notification_reads_admin_user_fk"
67
+ foreign key ("admin_user_id") references "admin_users" ("id") on delete cascade
68
+ );
69
+ `);
70
+ this.addSql(`
71
+ create index "admin_notification_reads_admin_user_idx"
72
+ on "admin_notification_reads" ("admin_user_id");
73
+ `);
74
+ }
75
+ async down() {
76
+ this.addSql(`drop table if exists "admin_notification_reads" cascade;`);
77
+ this.addSql(`drop index if exists "admin_notifications_audience_idx";`);
78
+ this.addSql(`drop index if exists "admin_notifications_unread_idx";`);
79
+ this.addSql(`drop table if exists "admin_notifications" cascade;`);
80
+ }
81
+ }
82
+ //# sourceMappingURL=20260611T140350_admin_notifications_init.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"20260611T140350_admin_notifications_init.js","sourceRoot":"","sources":["../../src/migrations/20260611T140350_admin_notifications_init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,8CAA+C,SAAQ,SAAS;IAClE,KAAK,CAAC,EAAE;QACf,IAAI,CAAC,MAAM,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;KAyBX,CAAC,CAAC;QAEH,qEAAqE;QACrE,gBAAgB;QAChB,IAAI,CAAC,MAAM,CAAC;;;KAGX,CAAC,CAAC;QAEH,gDAAgD;QAChD,IAAI,CAAC,MAAM,CAAC;;;;KAIX,CAAC,CAAC;QAEH,0DAA0D;QAC1D,yEAAyE;QACzE,IAAI,CAAC,MAAM,CAAC;;;;;;;;;;;;KAYX,CAAC,CAAC;QAEH,IAAI,CAAC,MAAM,CAAC;;;KAGX,CAAC,CAAC;IACL,CAAC;IAEQ,KAAK,CAAC,IAAI;QACjB,IAAI,CAAC,MAAM,CAAC,0DAA0D,CAAC,CAAC;QACxE,IAAI,CAAC,MAAM,CAAC,0DAA0D,CAAC,CAAC;QACxE,IAAI,CAAC,MAAM,CAAC,wDAAwD,CAAC,CAAC;QACtE,IAAI,CAAC,MAAM,CAAC,qDAAqD,CAAC,CAAC;IACrE,CAAC;CACF"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * The `./migrations` subpath — every migration class this module owns, as one
3
+ * ordered `migrations` array.
4
+ *
5
+ * The array is what the platform reads when this module is **installed**:
6
+ * `src/packages/package-runtime.ts` takes `exported['migrations']` and refuses
7
+ * the package outright when it is absent (D-168).
8
+ *
9
+ * Listed in ascending timestamp, which is the order of this module's own
10
+ * migrations and of nothing else (feature 081): a manifest `dependencies` array
11
+ * is the only thing ordering this block against another module's.
12
+ *
13
+ * The **named** exports stay beside the array, and the asymmetry with
14
+ * `./backend` — which publishes an array and no named class (D-168) — is
15
+ * deliberate. `db/migrations-registry.generated.ts` imports each class by name
16
+ * from this specifier, and a migration class name is contract in a way an entity
17
+ * class name is not: `mikro_orm_migrations` persists it, so it is a string every
18
+ * already-migrated database holds.
19
+ *
20
+ * A class that is in neither the array nor the barrel is a migration that does
21
+ * not run: `migration:pending` reports nothing pending and the first symptom is
22
+ * a query against a table nobody created.
23
+ */
24
+ import { Migration20260611T140350AdminNotificationsInit } from './20260611T140350_admin_notifications_init.js';
25
+ export declare const migrations: (typeof Migration20260611T140350AdminNotificationsInit)[];
26
+ export { Migration20260611T140350AdminNotificationsInit, };
27
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/migrations/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,8CAA8C,EAAE,MAAM,+CAA+C,CAAC;AAE/G,eAAO,MAAM,UAAU,2DAEtB,CAAC;AAEF,OAAO,EACL,8CAA8C,GAC/C,CAAC"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * The `./migrations` subpath — every migration class this module owns, as one
3
+ * ordered `migrations` array.
4
+ *
5
+ * The array is what the platform reads when this module is **installed**:
6
+ * `src/packages/package-runtime.ts` takes `exported['migrations']` and refuses
7
+ * the package outright when it is absent (D-168).
8
+ *
9
+ * Listed in ascending timestamp, which is the order of this module's own
10
+ * migrations and of nothing else (feature 081): a manifest `dependencies` array
11
+ * is the only thing ordering this block against another module's.
12
+ *
13
+ * The **named** exports stay beside the array, and the asymmetry with
14
+ * `./backend` — which publishes an array and no named class (D-168) — is
15
+ * deliberate. `db/migrations-registry.generated.ts` imports each class by name
16
+ * from this specifier, and a migration class name is contract in a way an entity
17
+ * class name is not: `mikro_orm_migrations` persists it, so it is a string every
18
+ * already-migrated database holds.
19
+ *
20
+ * A class that is in neither the array nor the barrel is a migration that does
21
+ * not run: `migration:pending` reports nothing pending and the first symptom is
22
+ * a query against a table nobody created.
23
+ */
24
+ import { Migration20260611T140350AdminNotificationsInit } from './20260611T140350_admin_notifications_init.js';
25
+ export const migrations = [
26
+ Migration20260611T140350AdminNotificationsInit,
27
+ ];
28
+ export { Migration20260611T140350AdminNotificationsInit, };
29
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/migrations/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,8CAA8C,EAAE,MAAM,+CAA+C,CAAC;AAE/G,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,8CAA8C;CAC/C,CAAC;AAEF,OAAO,EACL,8CAA8C,GAC/C,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,66 @@
1
1
  {
2
2
  "name": "@endora-commerce/mod-admin-notifications",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.100.0",
4
+ "type": "module",
5
+ "sideEffects": false,
6
+ "description": "In-app notification feed surfaced in the admin top-nav bell. Generic so any module can write entries.",
7
+ "license": "MIT",
8
+ "endora": {
9
+ "type": "module",
10
+ "id": "admin_notifications"
11
+ },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/endora-commerce/endora-commerce.git",
15
+ "directory": "packages/modules/admin_notifications"
16
+ },
17
+ "publishConfig": {
18
+ "access": "public"
19
+ },
20
+ "exports": {
21
+ ".": {
22
+ "types": "./dist/manifest.d.ts",
23
+ "default": "./dist/manifest.js"
24
+ },
25
+ "./backend": {
26
+ "types": "./dist/backend/index.d.ts",
27
+ "default": "./dist/backend/index.js"
28
+ },
29
+ "./migrations": {
30
+ "types": "./dist/migrations/index.d.ts",
31
+ "default": "./dist/migrations/index.js"
32
+ },
33
+ "./package.json": "./package.json"
34
+ },
35
+ "files": [
36
+ "dist"
37
+ ],
38
+ "engines": {
39
+ "node": ">=22.18.0"
40
+ },
41
+ "peerDependencies": {
42
+ "@mikro-orm/core": "^6",
43
+ "@mikro-orm/migrations": "^6",
44
+ "@mikro-orm/postgresql": "^6",
45
+ "fastify": "^5",
46
+ "zod": "^4",
47
+ "@endora-commerce/contracts": "0.100.0",
48
+ "@endora-commerce/platform": "0.100.0"
49
+ },
50
+ "devDependencies": {
51
+ "@mikro-orm/core": "^6.6.13",
52
+ "@mikro-orm/migrations": "^6.6.13",
53
+ "@mikro-orm/postgresql": "^6.6.13",
54
+ "@types/node": "^22.9.0",
55
+ "fastify": "^5.12.5",
56
+ "typescript": "^5.9.3",
57
+ "zod": "^4.2.0",
58
+ "@endora-commerce/contracts": "0.100.0",
59
+ "@endora-commerce/platform": "0.100.0"
60
+ },
61
+ "scripts": {
62
+ "build": "tsc -p tsconfig.build.json",
63
+ "typecheck": "tsc -p tsconfig.json",
64
+ "lint": "eslint src"
65
+ }
6
66
  }