hazo_notify 1.1.3 → 1.1.4
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 +98 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -64,10 +64,107 @@ For the template manager module, install the optional `hazo_connect` peer depend
|
|
|
64
64
|
npm install hazo_connect
|
|
65
65
|
```
|
|
66
66
|
|
|
67
|
-
Then
|
|
67
|
+
Then create the required tables (`hazo_notify_template_cat` and `hazo_notify_templates`) by running the appropriate SQL below for your database. The same SQL is also packaged at `node_modules/hazo_notify/migrations/001_create_template_tables.sql`.
|
|
68
68
|
|
|
69
69
|
If `hazo_connect` is not installed, the emailer module still works independently.
|
|
70
70
|
|
|
71
|
+
#### Database Tables
|
|
72
|
+
|
|
73
|
+
The template manager requires two tables:
|
|
74
|
+
|
|
75
|
+
| Table | Purpose |
|
|
76
|
+
|-------|---------|
|
|
77
|
+
| `hazo_notify_template_cat` | Template categories (groups templates per organization) |
|
|
78
|
+
| `hazo_notify_templates` | Email templates with HTML, text, and variable definitions |
|
|
79
|
+
|
|
80
|
+
Both tables are scoped by `org_id` and `root_org_id` for multi-tenant isolation. `hazo_notify_templates.template_category_id` references `hazo_notify_template_cat.id`.
|
|
81
|
+
|
|
82
|
+
#### PostgreSQL Schema
|
|
83
|
+
|
|
84
|
+
```sql
|
|
85
|
+
CREATE TABLE IF NOT EXISTS hazo_notify_template_cat (
|
|
86
|
+
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
87
|
+
org_id UUID NOT NULL,
|
|
88
|
+
root_org_id UUID NOT NULL,
|
|
89
|
+
template_category_name VARCHAR(100) NOT NULL,
|
|
90
|
+
created_at TIMESTAMPTZ DEFAULT NOW(),
|
|
91
|
+
changed_at TIMESTAMPTZ
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
CREATE INDEX IF NOT EXISTS idx_notify_template_cat_org
|
|
95
|
+
ON hazo_notify_template_cat (org_id);
|
|
96
|
+
|
|
97
|
+
CREATE TABLE IF NOT EXISTS hazo_notify_templates (
|
|
98
|
+
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
99
|
+
org_id UUID NOT NULL,
|
|
100
|
+
root_org_id UUID NOT NULL,
|
|
101
|
+
template_category_id UUID NOT NULL REFERENCES hazo_notify_template_cat(id),
|
|
102
|
+
template_variables JSONB DEFAULT '{}',
|
|
103
|
+
template_name VARCHAR(100) NOT NULL,
|
|
104
|
+
template_html TEXT NOT NULL DEFAULT '',
|
|
105
|
+
template_text TEXT NOT NULL DEFAULT '',
|
|
106
|
+
email_type VARCHAR(10) NOT NULL DEFAULT 'user',
|
|
107
|
+
created_at TIMESTAMPTZ DEFAULT NOW(),
|
|
108
|
+
changed_at TIMESTAMPTZ
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
CREATE INDEX IF NOT EXISTS idx_notify_templates_org
|
|
112
|
+
ON hazo_notify_templates (org_id);
|
|
113
|
+
|
|
114
|
+
CREATE INDEX IF NOT EXISTS idx_notify_templates_category
|
|
115
|
+
ON hazo_notify_templates (template_category_id);
|
|
116
|
+
|
|
117
|
+
CREATE INDEX IF NOT EXISTS idx_notify_templates_name
|
|
118
|
+
ON hazo_notify_templates (org_id, template_name);
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
#### SQLite Schema
|
|
122
|
+
|
|
123
|
+
```sql
|
|
124
|
+
CREATE TABLE IF NOT EXISTS hazo_notify_template_cat (
|
|
125
|
+
id TEXT PRIMARY KEY,
|
|
126
|
+
org_id TEXT NOT NULL,
|
|
127
|
+
root_org_id TEXT NOT NULL,
|
|
128
|
+
template_category_name TEXT NOT NULL,
|
|
129
|
+
created_at TEXT DEFAULT (datetime('now')),
|
|
130
|
+
changed_at TEXT
|
|
131
|
+
);
|
|
132
|
+
|
|
133
|
+
CREATE INDEX IF NOT EXISTS idx_notify_template_cat_org
|
|
134
|
+
ON hazo_notify_template_cat (org_id);
|
|
135
|
+
|
|
136
|
+
CREATE TABLE IF NOT EXISTS hazo_notify_templates (
|
|
137
|
+
id TEXT PRIMARY KEY,
|
|
138
|
+
org_id TEXT NOT NULL,
|
|
139
|
+
root_org_id TEXT NOT NULL,
|
|
140
|
+
template_category_id TEXT NOT NULL REFERENCES hazo_notify_template_cat(id),
|
|
141
|
+
template_variables TEXT DEFAULT '{}',
|
|
142
|
+
template_name TEXT NOT NULL,
|
|
143
|
+
template_html TEXT NOT NULL DEFAULT '',
|
|
144
|
+
template_text TEXT NOT NULL DEFAULT '',
|
|
145
|
+
email_type TEXT NOT NULL DEFAULT 'user',
|
|
146
|
+
created_at TEXT DEFAULT (datetime('now')),
|
|
147
|
+
changed_at TEXT
|
|
148
|
+
);
|
|
149
|
+
|
|
150
|
+
CREATE INDEX IF NOT EXISTS idx_notify_templates_org
|
|
151
|
+
ON hazo_notify_templates (org_id);
|
|
152
|
+
|
|
153
|
+
CREATE INDEX IF NOT EXISTS idx_notify_templates_category
|
|
154
|
+
ON hazo_notify_templates (template_category_id);
|
|
155
|
+
|
|
156
|
+
CREATE INDEX IF NOT EXISTS idx_notify_templates_name
|
|
157
|
+
ON hazo_notify_templates (org_id, template_name);
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
#### Type Mapping (PostgreSQL ↔ SQLite)
|
|
161
|
+
|
|
162
|
+
| Concept | PostgreSQL | SQLite |
|
|
163
|
+
|---------|------------|--------|
|
|
164
|
+
| Primary / foreign keys | `UUID` (with `gen_random_uuid()` default) | `TEXT` (UUID string supplied by app) |
|
|
165
|
+
| JSON column (`template_variables`) | `JSONB` | `TEXT` (serialized JSON) |
|
|
166
|
+
| Timestamps | `TIMESTAMPTZ` with `NOW()` default | `TEXT` with `datetime('now')` default |
|
|
167
|
+
|
|
71
168
|
## Quick Start
|
|
72
169
|
|
|
73
170
|
1. **Create `.env.local` file** with your Zeptomail API key:
|