notifkit 0.1.10 → 0.1.12
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 +37 -1
- package/dashboard/dist/assets/{index-7mvXb4bS.js → index-Bsrmo9LE.js} +1 -1
- package/dashboard/dist/assets/index-s-SXGIwv.css +1 -0
- package/dashboard/dist/index.html +2 -2
- package/dist/bootstrap-omGPIBny.mjs +89 -0
- package/dist/bulk-C4hTcnLu.mjs +77 -0
- package/dist/index.d.mts +1160 -8886
- package/dist/index.mjs +2 -38
- package/dist/{main-C9s-2ArH.mjs → main-B-AZ-xoN.mjs} +49 -75
- package/dist/main-B5BwjIMu.mjs +811 -0
- package/dist/{main-B3iQrl3t.mjs → main-BU27VjDC.mjs} +149 -134
- package/dist/main-Bes11Ad3.mjs +312 -0
- package/dist/{main-BiFiOX9D.mjs → main-BtnGmyaT.mjs} +119 -112
- package/dist/{main-39DtKrX4.mjs → main-BxAeC_k6.mjs} +395 -184
- package/dist/{main-Dz2sUh3c.mjs → main-DAXO-MiH.mjs} +57 -54
- package/dist/{main-BgmT1MPe.mjs → main-DYGCl7Ja.mjs} +135 -79
- package/dist/{src-QiTu5e_a.mjs → src-CIPTzq9i.mjs} +1351 -661
- package/drizzle/0006_message_logs_redundant_indexes.sql +7 -0
- package/drizzle/0007_workflow_status_canceled.sql +3 -0
- package/drizzle/meta/_journal.json +14 -0
- package/package.json +21 -18
- package/scripts/create-admin.mjs +8 -1
- package/scripts/migrate.mjs +43 -0
- package/src/client.ts +15 -5
- package/src/config/index.ts +37 -3
- package/src/contracts/events/notification-ai-pending.ts +12 -0
- package/src/contracts/events/notification-delivered.ts +7 -0
- package/src/contracts/events/notification-dispatched.ts +21 -2
- package/src/contracts/events/notification-enriched.ts +16 -0
- package/src/contracts/events/notification-failed.ts +2 -0
- package/src/contracts/events/notification-requested.ts +2 -0
- package/src/contracts/registry.ts +2 -2
- package/src/contracts/sdk.ts +77 -29
- package/src/db/bulk.ts +132 -0
- package/src/db/index.ts +174 -7
- package/src/db/schema.ts +3 -50
- package/src/idempotency/index.ts +60 -6
- package/src/logger/index.ts +0 -12
- package/src/queue/index.ts +255 -76
- package/src/rate-limiter/index.ts +217 -16
- package/src/redis/index.ts +265 -0
- package/src/repositories/index.ts +171 -82
- package/src/server.ts +64 -41
- package/src/services/ai/main.ts +83 -70
- package/src/services/api/admin-static.ts +41 -12
- package/src/services/api/handlers.ts +357 -159
- package/src/services/api/http.ts +34 -7
- package/src/services/api/main.ts +104 -67
- package/src/services/api/router.ts +18 -5
- package/src/services/delivery/main.ts +495 -230
- package/src/services/delivery/throttle.ts +42 -59
- package/src/services/engine/main.ts +206 -152
- package/src/services/enricher/main.ts +155 -107
- package/src/services/events/main.ts +100 -55
- package/src/services/scheduler/main.ts +151 -79
- package/src/services/scheduler/send-gate.ts +117 -0
- package/src/services/workflow/main.ts +220 -100
- package/src/shared/batch-processor.ts +65 -34
- package/src/shared/dataloader.ts +58 -22
- package/src/shared/events.ts +3 -0
- package/src/shared/index.ts +0 -1
- package/src/shared/utils.ts +2 -47
- package/src/templates/index.ts +0 -67
- package/src/transport/index.ts +6 -0
- package/src/workers/bootstrap.ts +124 -0
- package/src/workers/index.ts +99 -24
- package/src/workflows/sdk.ts +2 -0
- package/dashboard/dist/assets/index-o7L-f3-c.css +0 -1
- package/dist/index.d.mts.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/dist/main-39DtKrX4.mjs.map +0 -1
- package/dist/main-B3iQrl3t.mjs.map +0 -1
- package/dist/main-BM8DH3v3.mjs +0 -632
- package/dist/main-BM8DH3v3.mjs.map +0 -1
- package/dist/main-BgmT1MPe.mjs.map +0 -1
- package/dist/main-BiFiOX9D.mjs.map +0 -1
- package/dist/main-C9s-2ArH.mjs.map +0 -1
- package/dist/main-Cqo3rSb5.mjs +0 -224
- package/dist/main-Cqo3rSb5.mjs.map +0 -1
- package/dist/main-Dz2sUh3c.mjs.map +0 -1
- package/dist/src-QiTu5e_a.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -215,7 +215,41 @@ curl -X POST http://localhost:3000/v1/notify \
|
|
|
215
215
|
|
|
216
216
|
### Development vs. production
|
|
217
217
|
|
|
218
|
-
Locally, Docker is the only prerequisite: in development notifkit starts throwaway PostgreSQL and Redis containers for you. In production you need Node 22+, PostgreSQL, and Redis, and you run migrations
|
|
218
|
+
Locally, Docker is the only prerequisite: in development notifkit starts throwaway PostgreSQL and Redis containers for you. In production you need Node 22+, PostgreSQL, and Redis, and you run migrations with the bundled CLI before starting the server:
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
DATABASE_URL=postgres://user:pass@host:5432/db npx notifkit-migrate
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
`notifkit-migrate` reads `DATABASE_URL` and `DB_SCHEMA` (from the environment or `.env`), applies any pending migrations into that schema, and exits non-zero if anything fails, so it can gate a deploy. It is safe to run on every deploy. Do not point `drizzle-kit` at `node_modules/notifkit/drizzle` directly: that ignores `DB_SCHEMA` and always creates the tables in `public`. In the default `public` schema both use the same journal (`drizzle.__drizzle_migrations`), so an install migrated with `drizzle-kit` so far can switch to `notifkit-migrate` as is.
|
|
225
|
+
|
|
226
|
+
### Installing into a custom PostgreSQL schema
|
|
227
|
+
|
|
228
|
+
By default notifkit creates its tables and enum types in `public`. To share a database with an application that already owns `public`, set `DB_SCHEMA` (or `dbOptions.schema` on `NotifkitServer`):
|
|
229
|
+
|
|
230
|
+
```bash
|
|
231
|
+
DB_SCHEMA=notifications
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
Migrations (`notifkit-migrate`, or `autoMigrate` on start-up) then create the schema if it is missing and put every notifkit object into it, and every connection notifkit opens resolves queries against that schema only. After migrating, notifkit checks that every one of its tables exists in that schema and fails with the names of any that do not. The migration journal is kept in the same schema (`notifications.__drizzle_migrations`), so two installs in one database never share it. Pass `runMigrations(db, { schema, migrationsSchema, migrationsTable })` to run migrations yourself.
|
|
235
|
+
|
|
236
|
+
The schema is set as the `search_path` startup parameter. If a connection pooler in front of PostgreSQL rejects that parameter (PgBouncer does unless `search_path` is listed in `track_extra_parameters` or `ignore_startup_parameters`), set it on the role instead: `ALTER ROLE <role> SET search_path = notifications`.
|
|
237
|
+
|
|
238
|
+
> [!WARNING]
|
|
239
|
+
> **Do not set `DB_SCHEMA` on an install that already runs in `public`.** Nothing is moved for you: notifkit creates a fresh, empty set of tables in the new schema and stops looking at `public`. The application then looks empty: admin logins and every project API key stop working, and users, templates and history are gone from its point of view (the data is still in `public`, just no longer read).
|
|
240
|
+
>
|
|
241
|
+
> To move an existing install, stop notifkit and move **every** notifkit table and enum type, plus the migration journal, into the new schema yourself **before** running `notifkit-migrate` with the new `DB_SCHEMA`, for example:
|
|
242
|
+
>
|
|
243
|
+
> ```sql
|
|
244
|
+
> BEGIN;
|
|
245
|
+
> CREATE SCHEMA notifications;
|
|
246
|
+
> ALTER TABLE public.projects SET SCHEMA notifications; -- repeat for every table in notifkitTableNames()
|
|
247
|
+
> ALTER TYPE public.channel SET SCHEMA notifications; -- and for api_key_role, workflow_status
|
|
248
|
+
> ALTER TABLE drizzle.__drizzle_migrations SET SCHEMA notifications;
|
|
249
|
+
> COMMIT;
|
|
250
|
+
> ```
|
|
251
|
+
>
|
|
252
|
+
> Then `notifkit-migrate` finds the journal, applies nothing it has already applied, and confirms that every table is in place.
|
|
219
253
|
|
|
220
254
|
## Running in production
|
|
221
255
|
|
|
@@ -348,6 +382,8 @@ You can also create or update admin users at any time via the CLI:
|
|
|
348
382
|
npx notifkit-create-admin admin@example.com supersecretpassword123
|
|
349
383
|
```
|
|
350
384
|
|
|
385
|
+
Like `notifkit-migrate`, it reads `DATABASE_URL` and `DB_SCHEMA`.
|
|
386
|
+
|
|
351
387
|
In production, the pre-built dashboard bundle in `dashboard/dist` is served automatically. In development, run `npm --prefix dashboard run dev` to start the Vite development server with hot module replacement (the API server automatically proxies `/admin` requests to port 5173).
|
|
352
388
|
|
|
353
389
|
## Documentation
|