notiformer 1.0.2 → 1.0.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/dist/index.d.ts +17 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +41 -50
- package/dist/index.js.map +1 -1
- package/dist/logger.d.ts +1 -1
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +2 -1
- package/dist/logger.js.map +1 -1
- package/dist/types.d.ts +22 -42
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +0 -3
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,23 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Notiformer — Real-time alerts and feature gates for your code.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* Your API key would be exposed publicly.
|
|
6
|
-
* Use in: Node.js, Express, Next.js API routes, serverless functions.
|
|
4
|
+
* Works in Node.js (backend) and the browser (frontend).
|
|
7
5
|
*
|
|
8
6
|
* @example
|
|
9
7
|
* import { Notiformer } from 'notiformer';
|
|
10
8
|
*
|
|
11
|
-
* const n = new Notiformer({
|
|
12
|
-
*
|
|
13
|
-
*
|
|
9
|
+
* const n = new Notiformer({ apiKey: 'ntf_live_...' });
|
|
10
|
+
*
|
|
11
|
+
* // Notify everyone subscribed to the 'payments' channel
|
|
12
|
+
* await n.event({ channel: 'payments', event: 'new_sale', notify: true });
|
|
14
13
|
*
|
|
14
|
+
* // Notify specific people only
|
|
15
15
|
* await n.event({
|
|
16
16
|
* channel: 'payments',
|
|
17
|
-
* event: '
|
|
18
|
-
* description: '$49.00 — john@example.com',
|
|
19
|
-
* icon: '💳',
|
|
17
|
+
* event: 'refund_requested',
|
|
20
18
|
* notify: true,
|
|
19
|
+
* recipients: ['admin@company.com', 'billing@company.com'],
|
|
21
20
|
* });
|
|
22
21
|
*/
|
|
23
22
|
import type { NotiformerConfig, EventPayload, EventResponse, GateOptions, GateResult } from "./types";
|
|
@@ -34,22 +33,23 @@ export declare class Notiformer {
|
|
|
34
33
|
private readonly isPlaceholder;
|
|
35
34
|
constructor(config: NotiformerConfig);
|
|
36
35
|
/**
|
|
37
|
-
* Send an event and optionally
|
|
36
|
+
* Send an event and optionally notify recipients.
|
|
38
37
|
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
38
|
+
* - Without `recipients`: notifies the project owner + all members
|
|
39
|
+
* subscribed to the event's channel.
|
|
40
|
+
* - With `recipients`: notifies only the specified email addresses
|
|
41
|
+
* (must be project members). Overrides the default behaviour.
|
|
42
|
+
*
|
|
43
|
+
* Never throws by default — returns null if the call fails.
|
|
41
44
|
*/
|
|
42
45
|
event(payload: EventPayload): Promise<EventResponse | null>;
|
|
43
46
|
/**
|
|
44
47
|
* Check whether a feature gate is enabled.
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
* Returns fallback (false) if the call fails.
|
|
48
|
+
* Results are cached locally for 30 seconds by default.
|
|
49
|
+
* Returns false if the call fails.
|
|
48
50
|
*/
|
|
49
51
|
gate(key: string, options?: GateOptions): Promise<boolean>;
|
|
50
|
-
/** Full gate result with metadata */
|
|
51
52
|
gateDetails(key: string, options?: GateOptions): Promise<GateResult>;
|
|
52
|
-
/** Clear cached gate values */
|
|
53
53
|
clearGateCache(key?: string): void;
|
|
54
54
|
private post;
|
|
55
55
|
private get;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EACV,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,WAAW,EACX,UAAU,EACX,MAAM,SAAS,CAAC;AAIjB,YAAY,EACV,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,WAAW,EACX,UAAU,GACX,CAAC;AAOF,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAU;IACjC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAU;IACvC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAA8B;IACvD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAY;IACtC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAU;gBAE5B,MAAM,EAAE,gBAAgB;IAoCpC;;;;;;;;;OASG;IACG,KAAK,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAiDjE;;;;OAIG;IACG,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB,GAAG,OAAO,CAAC,OAAO,CAAC;IAsB9D,WAAW,CACf,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,WAAgB,GACxB,OAAO,CAAC,UAAU,CAAC;IAKtB,cAAc,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI;YAIpB,IAAI;YAIJ,GAAG;YAIH,OAAO;IAmBrB,OAAO,CAAC,IAAI;IAOZ,OAAO,CAAC,oBAAoB;CAmB7B;AAED,eAAe,UAAU,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -2,30 +2,28 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Notiformer — Real-time alerts and feature gates for your code.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
* Your API key would be exposed publicly.
|
|
7
|
-
* Use in: Node.js, Express, Next.js API routes, serverless functions.
|
|
5
|
+
* Works in Node.js (backend) and the browser (frontend).
|
|
8
6
|
*
|
|
9
7
|
* @example
|
|
10
8
|
* import { Notiformer } from 'notiformer';
|
|
11
9
|
*
|
|
12
|
-
* const n = new Notiformer({
|
|
13
|
-
*
|
|
14
|
-
*
|
|
10
|
+
* const n = new Notiformer({ apiKey: 'ntf_live_...' });
|
|
11
|
+
*
|
|
12
|
+
* // Notify everyone subscribed to the 'payments' channel
|
|
13
|
+
* await n.event({ channel: 'payments', event: 'new_sale', notify: true });
|
|
15
14
|
*
|
|
15
|
+
* // Notify specific people only
|
|
16
16
|
* await n.event({
|
|
17
17
|
* channel: 'payments',
|
|
18
|
-
* event: '
|
|
19
|
-
* description: '$49.00 — john@example.com',
|
|
20
|
-
* icon: '💳',
|
|
18
|
+
* event: 'refund_requested',
|
|
21
19
|
* notify: true,
|
|
20
|
+
* recipients: ['admin@company.com', 'billing@company.com'],
|
|
22
21
|
* });
|
|
23
22
|
*/
|
|
24
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
24
|
exports.Notiformer = void 0;
|
|
26
25
|
const logger_1 = require("./logger");
|
|
27
26
|
const cache_1 = require("./cache");
|
|
28
|
-
// The placeholder key shown in docs — triggers a friendly setup message
|
|
29
27
|
const PLACEHOLDER_KEY = "ntf_live_test";
|
|
30
28
|
const API_URL = "https://api.notiformer.com";
|
|
31
29
|
const DEFAULT_TIMEOUT = 8000;
|
|
@@ -51,7 +49,7 @@ class Notiformer {
|
|
|
51
49
|
"┌─────────────────────────────────────────────────────┐\n" +
|
|
52
50
|
"│ notiformer — setup required │\n" +
|
|
53
51
|
"├─────────────────────────────────────────────────────┤\n" +
|
|
54
|
-
'│ You are using the example
|
|
52
|
+
'│ You are using the example key "ntf_live_test". │\n' +
|
|
55
53
|
"│ Events will not be sent until you use a real key. │\n" +
|
|
56
54
|
"│ │\n" +
|
|
57
55
|
"│ 1. Go to https://app.notiformer.com/projects │\n" +
|
|
@@ -61,14 +59,15 @@ class Notiformer {
|
|
|
61
59
|
"└─────────────────────────────────────────────────────┘\n");
|
|
62
60
|
}
|
|
63
61
|
}
|
|
64
|
-
// ─────────────────────────────────────────────────────────────
|
|
65
|
-
// event()
|
|
66
|
-
// ─────────────────────────────────────────────────────────────
|
|
67
62
|
/**
|
|
68
|
-
* Send an event and optionally
|
|
63
|
+
* Send an event and optionally notify recipients.
|
|
69
64
|
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
65
|
+
* - Without `recipients`: notifies the project owner + all members
|
|
66
|
+
* subscribed to the event's channel.
|
|
67
|
+
* - With `recipients`: notifies only the specified email addresses
|
|
68
|
+
* (must be project members). Overrides the default behaviour.
|
|
69
|
+
*
|
|
70
|
+
* Never throws by default — returns null if the call fails.
|
|
72
71
|
*/
|
|
73
72
|
async event(payload) {
|
|
74
73
|
var _a, _b;
|
|
@@ -76,31 +75,36 @@ class Notiformer {
|
|
|
76
75
|
throw new Error("[notiformer] event.channel is required.");
|
|
77
76
|
if (!payload.event)
|
|
78
77
|
throw new Error("[notiformer] event.event is required.");
|
|
79
|
-
// Placeholder key — log a clear message, do not attempt the call
|
|
80
78
|
if (this.isPlaceholder) {
|
|
81
|
-
console.warn('[notiformer] Event not sent —
|
|
82
|
-
"→ Replace it with your real
|
|
79
|
+
console.warn('[notiformer] Event not sent — using example key "ntf_live_test".\n' +
|
|
80
|
+
"→ Replace it with your real key from https://app.notiformer.com/projects");
|
|
83
81
|
return null;
|
|
84
82
|
}
|
|
85
|
-
if (this.silent)
|
|
86
|
-
this.logger.info("Silent mode: event suppressed.");
|
|
83
|
+
if (this.silent)
|
|
87
84
|
return null;
|
|
88
|
-
}
|
|
89
85
|
try {
|
|
90
|
-
const
|
|
86
|
+
const body = {
|
|
91
87
|
channel: payload.channel,
|
|
92
88
|
event: payload.event,
|
|
93
|
-
description: payload.description,
|
|
94
|
-
icon: payload.icon,
|
|
95
|
-
tags: payload.tags,
|
|
96
|
-
value: payload.value,
|
|
97
89
|
notify: (_a = payload.notify) !== null && _a !== void 0 ? _a : true,
|
|
98
|
-
}
|
|
90
|
+
};
|
|
91
|
+
if (payload.description !== undefined)
|
|
92
|
+
body.description = payload.description;
|
|
93
|
+
if (payload.icon !== undefined)
|
|
94
|
+
body.icon = payload.icon;
|
|
95
|
+
if (payload.tags !== undefined)
|
|
96
|
+
body.tags = payload.tags;
|
|
97
|
+
if (payload.value !== undefined)
|
|
98
|
+
body.value = payload.value;
|
|
99
|
+
if (payload.recipients !== undefined && payload.recipients.length > 0) {
|
|
100
|
+
body.recipients = payload.recipients;
|
|
101
|
+
}
|
|
102
|
+
const res = await this.post("/v1/events", body);
|
|
99
103
|
if (!res.ok) {
|
|
100
|
-
const
|
|
104
|
+
const data = await res
|
|
101
105
|
.json()
|
|
102
106
|
.catch(() => ({ error: `HTTP ${res.status}` }));
|
|
103
|
-
return this.fail(new Error(`[notiformer] ${(_b =
|
|
107
|
+
return this.fail(new Error(`[notiformer] ${(_b = data.error) !== null && _b !== void 0 ? _b : res.statusText}`));
|
|
104
108
|
}
|
|
105
109
|
return (await res.json());
|
|
106
110
|
}
|
|
@@ -108,14 +112,10 @@ class Notiformer {
|
|
|
108
112
|
return this.fail(this.friendlyNetworkError(err));
|
|
109
113
|
}
|
|
110
114
|
}
|
|
111
|
-
// ─────────────────────────────────────────────────────────────
|
|
112
|
-
// gate()
|
|
113
|
-
// ─────────────────────────────────────────────────────────────
|
|
114
115
|
/**
|
|
115
116
|
* Check whether a feature gate is enabled.
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
* Returns fallback (false) if the call fails.
|
|
117
|
+
* Results are cached locally for 30 seconds by default.
|
|
118
|
+
* Returns false if the call fails.
|
|
119
119
|
*/
|
|
120
120
|
async gate(key, options = {}) {
|
|
121
121
|
var _a, _b;
|
|
@@ -140,23 +140,15 @@ class Notiformer {
|
|
|
140
140
|
return fallback;
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
|
-
/** Full gate result with metadata */
|
|
144
143
|
async gateDetails(key, options = {}) {
|
|
145
144
|
const enabled = await this.gate(key, options);
|
|
146
145
|
return { key, enabled, cached: false, fetchedAt: new Date().toISOString() };
|
|
147
146
|
}
|
|
148
|
-
/** Clear cached gate values */
|
|
149
147
|
clearGateCache(key) {
|
|
150
148
|
key ? this.gateCache.delete(key) : this.gateCache.clear();
|
|
151
149
|
}
|
|
152
|
-
// ─────────────────────────────────────────────────────────────
|
|
153
|
-
// Private
|
|
154
|
-
// ─────────────────────────────────────────────────────────────
|
|
155
150
|
async post(path, body) {
|
|
156
|
-
return this.request(path, {
|
|
157
|
-
method: "POST",
|
|
158
|
-
body: JSON.stringify(body),
|
|
159
|
-
});
|
|
151
|
+
return this.request(path, { method: "POST", body: JSON.stringify(body) });
|
|
160
152
|
}
|
|
161
153
|
async get(path) {
|
|
162
154
|
return this.request(path, { method: "GET" });
|
|
@@ -172,7 +164,7 @@ class Notiformer {
|
|
|
172
164
|
headers: {
|
|
173
165
|
"Content-Type": "application/json",
|
|
174
166
|
Authorization: `Bearer ${this.apiKey}`,
|
|
175
|
-
"X-SDK-Version": "1.0.
|
|
167
|
+
"X-SDK-Version": "1.0.4",
|
|
176
168
|
...((_a = init.headers) !== null && _a !== void 0 ? _a : {}),
|
|
177
169
|
},
|
|
178
170
|
});
|
|
@@ -192,14 +184,13 @@ class Notiformer {
|
|
|
192
184
|
friendlyNetworkError(err) {
|
|
193
185
|
const msg = err instanceof Error ? err.message.toLowerCase() : "";
|
|
194
186
|
if (msg.includes("aborted") || msg.includes("timeout")) {
|
|
195
|
-
return new Error(`[notiformer] Request timed out after ${this.timeout / 1000}s
|
|
196
|
-
"Check your internet connection or try again later.");
|
|
187
|
+
return new Error(`[notiformer] Request timed out after ${this.timeout / 1000}s.`);
|
|
197
188
|
}
|
|
198
189
|
if (msg.includes("failed to fetch") ||
|
|
199
190
|
msg.includes("enotfound") ||
|
|
200
191
|
msg.includes("network")) {
|
|
201
192
|
return new Error("[notiformer] Cannot reach the Notiformer API.\n" +
|
|
202
|
-
"Check your
|
|
193
|
+
"Check your connection. If the issue persists: https://status.notiformer.com");
|
|
203
194
|
}
|
|
204
195
|
return err instanceof Error ? err : new Error(String(err));
|
|
205
196
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AASH,qCAAkC;AAClC,mCAAoC;AAUpC,MAAM,eAAe,GAAG,eAAe,CAAC;AACxC,MAAM,OAAO,GAAG,4BAA4B,CAAC;AAC7C,MAAM,eAAe,GAAG,IAAK,CAAC;AAC9B,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAE5B,MAAa,UAAU;IAWrB,YAAY,MAAwB;;QAClC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CACb,oCAAoC;gBAClC,oDAAoD,CACvD,CAAC;QACJ,CAAC;QAED,IAAI,CAAC,aAAa,GAAG,MAAM,CAAC,MAAM,KAAK,eAAe,CAAC;QACvD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAC,OAAO,GAAG,CAAC,MAAA,MAAM,CAAC,QAAQ,mCAAI,OAAO,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAC/D,IAAI,CAAC,OAAO,GAAG,eAAe,CAAC;QAC/B,IAAI,CAAC,MAAM,GAAG,MAAA,MAAM,CAAC,MAAM,mCAAI,KAAK,CAAC;QACrC,IAAI,CAAC,YAAY,GAAG,MAAA,MAAM,CAAC,YAAY,mCAAI,KAAK,CAAC;QACjD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;QAC9B,IAAI,CAAC,MAAM,GAAG,IAAI,eAAM,CAAC,MAAM,CAAC,CAAC;QACjC,IAAI,CAAC,SAAS,GAAG,IAAI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AAO,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAClE,IAAI,GAAG,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;YACvD,OAAO,IAAI,KAAK,CACd,wCAAwC,IAAI,CAAC,OAAO,GAAG,IAAI,IAAI,CAChE,CAAC;QACJ,CAAC;QACD,IACE,GAAG,CAAC,QAAQ,CAAC,iBAAiB,CAAC;YAC/B,GAAG,CAAC,QAAQ,CAAC,WAAW,CAAC;YACzB,GAAG,CAAC,QAAQ,CAAC,SAAS,CAAC,EACvB,CAAC;YACD,OAAO,IAAI,KAAK,CACd,iDAAiD;gBAC/C,6EAA6E,CAChF,CAAC;QACJ,CAAC;QACD,OAAO,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;IAC7D,CAAC;CACF;AAtMD,gCAsMC;AAED,kBAAe,UAAU,CAAC"}
|
package/dist/logger.d.ts
CHANGED
package/dist/logger.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAWxC,qBAAa,MAAM;IACjB,OAAO,CAAC,KAAK,CAAS;gBAEV,KAAK,GAAE,QAAkB;IAIrC,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAK5C,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAI3C,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAI3C,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;CAI7C"}
|
package/dist/logger.js
CHANGED
package/dist/logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":";;;AAEA,MAAM,MAAM,GAA6B;IACvC,KAAK,EAAE,CAAC;IACR,IAAI,EAAE,CAAC;IACP,IAAI,EAAE,CAAC;IACP,KAAK,EAAE,CAAC;IACR,IAAI,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":";;;AAEA,MAAM,MAAM,GAA6B;IACvC,KAAK,EAAE,CAAC;IACR,IAAI,EAAE,CAAC;IACP,IAAI,EAAE,CAAC;IACP,KAAK,EAAE,CAAC;IACR,IAAI,EAAE,CAAC;IACP,MAAM,EAAE,CAAC;CACV,CAAC;AAEF,MAAa,MAAM;IAGjB,YAAY,QAAkB,OAAO;QACnC,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC7B,CAAC;IAED,KAAK,CAAC,GAAW,EAAE,GAAG,IAAe;QACnC,IAAI,IAAI,CAAC,KAAK,IAAI,MAAM,CAAC,KAAK;YAC5B,OAAO,CAAC,KAAK,CAAC,gBAAgB,GAAG,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;IAClD,CAAC;IAED,IAAI,CAAC,GAAW,EAAE,GAAG,IAAe;QAClC,IAAI,IAAI,CAAC,KAAK,IAAI,MAAM,CAAC,IAAI;YAAE,OAAO,CAAC,IAAI,CAAC,gBAAgB,GAAG,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;IAC9E,CAAC;IAED,IAAI,CAAC,GAAW,EAAE,GAAG,IAAe;QAClC,IAAI,IAAI,CAAC,KAAK,IAAI,MAAM,CAAC,IAAI;YAAE,OAAO,CAAC,IAAI,CAAC,gBAAgB,GAAG,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;IAC9E,CAAC;IAED,KAAK,CAAC,GAAW,EAAE,GAAG,IAAe;QACnC,IAAI,IAAI,CAAC,KAAK,IAAI,MAAM,CAAC,KAAK;YAC5B,OAAO,CAAC,KAAK,CAAC,gBAAgB,GAAG,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;IAClD,CAAC;CACF;AAxBD,wBAwBC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,67 +1,47 @@
|
|
|
1
1
|
export interface NotiformerConfig {
|
|
2
|
-
/**
|
|
3
|
-
* Your Notiformer API key.
|
|
4
|
-
* Find it at: https://app.notiformer.com/projects
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* const n = new Notiformer({ apiKey: 'ntf_live_xxxxxxxxxxxxxxxx' })
|
|
8
|
-
*/
|
|
9
2
|
apiKey: string;
|
|
10
|
-
/**
|
|
11
|
-
* Silence all SDK calls. Useful for local development.
|
|
12
|
-
* No events will be sent, no network calls made.
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* const n = new Notiformer({
|
|
16
|
-
* apiKey: process.env.NOTIFORMER_API_KEY,
|
|
17
|
-
* silent: process.env.NODE_ENV !== 'production',
|
|
18
|
-
* })
|
|
19
|
-
*/
|
|
20
3
|
silent?: boolean;
|
|
21
|
-
/**
|
|
22
|
-
* Called when an event() or gate() call fails.
|
|
23
|
-
* Use this to forward errors to your own logging system.
|
|
24
|
-
*
|
|
25
|
-
* @example
|
|
26
|
-
* onError: (err) => console.error('[notiformer]', err.message)
|
|
27
|
-
*/
|
|
28
|
-
onError?: (error: Error) => void;
|
|
29
|
-
/**
|
|
30
|
-
* If true, throws on failure instead of returning null silently.
|
|
31
|
-
* Default: false — a failed notification should never crash your app.
|
|
32
|
-
*/
|
|
33
4
|
throwOnError?: boolean;
|
|
34
|
-
|
|
5
|
+
onError?: (err: Error) => void;
|
|
35
6
|
_baseUrl?: string;
|
|
36
7
|
}
|
|
37
8
|
export interface EventPayload {
|
|
38
|
-
/** Channel name
|
|
9
|
+
/** Channel name (lowercase, letters, numbers, hyphens, underscores). */
|
|
39
10
|
channel: string;
|
|
40
|
-
/**
|
|
11
|
+
/** Short event name. */
|
|
41
12
|
event: string;
|
|
42
|
-
/** Human-readable description shown in the dashboard */
|
|
43
13
|
description?: string;
|
|
44
|
-
/** Emoji icon shown in the feed */
|
|
45
14
|
icon?: string;
|
|
46
|
-
/** Optional key/value metadata for filtering */
|
|
47
15
|
tags?: Record<string, string | number | boolean>;
|
|
48
|
-
/** A value to display alongside the event. e.g. '$49.00' */
|
|
49
16
|
value?: string | number;
|
|
50
17
|
/**
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
* @default true
|
|
18
|
+
* Whether to send push/email notifications.
|
|
19
|
+
* Defaults to true.
|
|
54
20
|
*/
|
|
55
21
|
notify?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Specific email addresses to notify.
|
|
24
|
+
*
|
|
25
|
+
* If set, **only** these emails receive notifications — the default
|
|
26
|
+
* (owner + channel subscribers) is ignored.
|
|
27
|
+
*
|
|
28
|
+
* Each email must belong to a member of your project
|
|
29
|
+
* (added from the Notiformer dashboard).
|
|
30
|
+
*
|
|
31
|
+
* Plan limits: Free=1, Starter=3, Pro=10, Business=30.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* recipients: ['alice@company.com', 'bob@company.com']
|
|
35
|
+
*/
|
|
36
|
+
recipients?: string[];
|
|
56
37
|
}
|
|
57
38
|
export interface EventResponse {
|
|
58
39
|
id: string;
|
|
59
40
|
createdAt: string;
|
|
41
|
+
rateLimited?: boolean;
|
|
60
42
|
}
|
|
61
43
|
export interface GateOptions {
|
|
62
|
-
/** Returned if the request fails. @default false */
|
|
63
44
|
fallback?: boolean;
|
|
64
|
-
/** Cache duration in seconds. 0 to disable. @default 30 */
|
|
65
45
|
cacheTtl?: number;
|
|
66
46
|
}
|
|
67
47
|
export interface GateResult {
|
|
@@ -70,5 +50,5 @@ export interface GateResult {
|
|
|
70
50
|
cached: boolean;
|
|
71
51
|
fetchedAt: string;
|
|
72
52
|
}
|
|
73
|
-
export type LogLevel =
|
|
53
|
+
export type LogLevel = "debug" | "info" | "warn" | "error" | "none" | "silent";
|
|
74
54
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,KAAK,KAAK,IAAI,CAAC;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,YAAY;IAC3B,wEAAwE;IACxE,OAAO,EAAE,MAAM,CAAC;IAChB,wBAAwB;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC;IACjD,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;;;;;;;;;;;OAaG;IACH,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;CACvB;AAED,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,UAAU;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAC"}
|
package/dist/types.js
CHANGED
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|