@fonderie/courier 1.0.0 → 1.0.1

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.
@@ -0,0 +1,3 @@
1
+ declare const getMigrationsPath: () => string;
2
+
3
+ export { getMigrationsPath };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fonderie/courier",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Transactional messaging for SaaS — multi-channel delivery (email, SMS, push) with FS or DB templates, per-message-type channel routing, and a persistent message log.",
5
5
  "keywords": [
6
6
  "fonderie-js",
@@ -39,7 +39,7 @@
39
39
  "module": "./dist/index.js",
40
40
  "types": "./dist/index.d.ts",
41
41
  "scripts": {
42
- "build": "tsup && node -e \"require('node:fs').cpSync('src/migrations/sql', 'dist/migrations/sql', {recursive:true})\"",
42
+ "build": "tsup && tsup --config tsup.migrations.ts",
43
43
  "dev": "tsup --watch",
44
44
  "typecheck": "tsc --noEmit",
45
45
  "test": "tsx --test src/__tests__/*.test.ts",
@@ -51,9 +51,9 @@
51
51
  "nodemailer": "^8.0.7"
52
52
  },
53
53
  "peerDependencies": {
54
- "@fonderie/core": "^0.1.0",
55
- "@fonderie/store": "^0.1.0",
56
- "@fonderie/events": "^1.0.0"
54
+ "@fonderie/core": "^0.1.1",
55
+ "@fonderie/store": "^0.1.1",
56
+ "@fonderie/events": "^1.0.1"
57
57
  },
58
58
  "peerDependenciesMeta": {
59
59
  "@fonderie/store": {
@@ -1,34 +0,0 @@
1
- -- fonderie_courier_templates: per-type, per-locale message templates
2
- CREATE TABLE IF NOT EXISTS fonderie_courier_templates (
3
- id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
4
- type TEXT NOT NULL,
5
- locale TEXT, -- NULL = default / catch-all locale
6
- subject TEXT,
7
- html TEXT,
8
- text TEXT NOT NULL,
9
- active BOOLEAN NOT NULL DEFAULT true,
10
- created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
11
- updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
12
- UNIQUE (type, locale)
13
- );
14
-
15
- CREATE INDEX IF NOT EXISTS idx_fct_type
16
- ON fonderie_courier_templates (type) WHERE active = true;
17
-
18
- -- fonderie_message_log: audit trail of every dispatch attempt
19
- CREATE TABLE IF NOT EXISTS fonderie_message_log (
20
- id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
21
- message_type TEXT NOT NULL,
22
- channel TEXT NOT NULL,
23
- recipient TEXT NOT NULL,
24
- locale TEXT,
25
- status TEXT NOT NULL DEFAULT 'pending',
26
- error TEXT,
27
- attempts INT NOT NULL DEFAULT 0,
28
- created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
29
- sent_at TIMESTAMPTZ
30
- );
31
-
32
- CREATE INDEX IF NOT EXISTS idx_fml_type ON fonderie_message_log (message_type);
33
- CREATE INDEX IF NOT EXISTS idx_fml_status ON fonderie_message_log (status);
34
- CREATE INDEX IF NOT EXISTS idx_fml_created ON fonderie_message_log (created_at DESC);
@@ -1,49 +0,0 @@
1
- -- Seed default email templates
2
- -- Uses UPDATE + conditional INSERT to safely handle NULL locale (ON CONFLICT
3
- -- does not fire for NULL columns in standard Postgres unique indexes).
4
-
5
- -- email-verification — variables: pin, firstName
6
- DO $$
7
- BEGIN
8
- IF EXISTS (
9
- SELECT 1 FROM fonderie_courier_templates
10
- WHERE type = 'email-verification' AND locale IS NULL
11
- ) THEN
12
- UPDATE fonderie_courier_templates
13
- SET
14
- subject = 'Your verification code',
15
- html = '<p>Hi {{firstName}},</p>
16
- <p>Your email verification code is:</p>
17
- <h2 style="letter-spacing:0.2em;">{{pin}}</h2>
18
- <p>Enter this code to complete your registration. It expires in 24 hours.</p>
19
- <p>If you did not create an account, you can safely ignore this email.</p>',
20
- text = 'Hi {{firstName}},
21
-
22
- Your email verification code is: {{pin}}
23
-
24
- Enter this code to complete your registration. It expires in 24 hours.
25
-
26
- If you did not create an account, you can safely ignore this email.',
27
- updated_at = now()
28
- WHERE type = 'email-verification' AND locale IS NULL;
29
- ELSE
30
- INSERT INTO fonderie_courier_templates (type, locale, subject, html, text)
31
- VALUES (
32
- 'email-verification',
33
- NULL,
34
- 'Your verification code',
35
- '<p>Hi {{firstName}},</p>
36
- <p>Your email verification code is:</p>
37
- <h2 style="letter-spacing:0.2em;">{{pin}}</h2>
38
- <p>Enter this code to complete your registration. It expires in 24 hours.</p>
39
- <p>If you did not create an account, you can safely ignore this email.</p>',
40
- 'Hi {{firstName}},
41
-
42
- Your email verification code is: {{pin}}
43
-
44
- Enter this code to complete your registration. It expires in 24 hours.
45
-
46
- If you did not create an account, you can safely ignore this email.'
47
- );
48
- END IF;
49
- END $$;
@@ -1,12 +0,0 @@
1
- -- Extend fonderie_message_log for delivery event correlation
2
- ALTER TABLE fonderie_message_log
3
- ADD COLUMN IF NOT EXISTS provider TEXT,
4
- ADD COLUMN IF NOT EXISTS provider_message_id TEXT,
5
- ADD COLUMN IF NOT EXISTS opened_at TIMESTAMPTZ,
6
- ADD COLUMN IF NOT EXISTS clicked_at TIMESTAMPTZ,
7
- ADD COLUMN IF NOT EXISTS bounced_at TIMESTAMPTZ,
8
- ADD COLUMN IF NOT EXISTS bounce_reason TEXT;
9
-
10
- CREATE INDEX IF NOT EXISTS idx_fml_provider_msg_id
11
- ON fonderie_message_log (provider_message_id)
12
- WHERE provider_message_id IS NOT NULL;