notiformer 1.0.3 → 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 +18 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +42 -47
- 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,19 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Notiformer — Real-time alerts and feature gates for your code.
|
|
3
3
|
*
|
|
4
|
+
* Works in Node.js (backend) and the browser (frontend).
|
|
5
|
+
*
|
|
4
6
|
* @example
|
|
5
7
|
* import { Notiformer } from 'notiformer';
|
|
6
8
|
*
|
|
7
|
-
* const n = new Notiformer({
|
|
8
|
-
*
|
|
9
|
-
*
|
|
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 });
|
|
10
13
|
*
|
|
14
|
+
* // Notify specific people only
|
|
11
15
|
* await n.event({
|
|
12
16
|
* channel: 'payments',
|
|
13
|
-
* event: '
|
|
14
|
-
* description: '$49.00 — john@example.com',
|
|
15
|
-
* icon: '💳',
|
|
17
|
+
* event: 'refund_requested',
|
|
16
18
|
* notify: true,
|
|
19
|
+
* recipients: ['admin@company.com', 'billing@company.com'],
|
|
17
20
|
* });
|
|
18
21
|
*/
|
|
19
22
|
import type { NotiformerConfig, EventPayload, EventResponse, GateOptions, GateResult } from "./types";
|
|
@@ -30,22 +33,23 @@ export declare class Notiformer {
|
|
|
30
33
|
private readonly isPlaceholder;
|
|
31
34
|
constructor(config: NotiformerConfig);
|
|
32
35
|
/**
|
|
33
|
-
* Send an event and optionally
|
|
36
|
+
* Send an event and optionally notify recipients.
|
|
34
37
|
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
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.
|
|
37
44
|
*/
|
|
38
45
|
event(payload: EventPayload): Promise<EventResponse | null>;
|
|
39
46
|
/**
|
|
40
47
|
* Check whether a feature gate is enabled.
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
* Returns fallback (false) if the call fails.
|
|
48
|
+
* Results are cached locally for 30 seconds by default.
|
|
49
|
+
* Returns false if the call fails.
|
|
44
50
|
*/
|
|
45
51
|
gate(key: string, options?: GateOptions): Promise<boolean>;
|
|
46
|
-
/** Full gate result with metadata */
|
|
47
52
|
gateDetails(key: string, options?: GateOptions): Promise<GateResult>;
|
|
48
|
-
/** Clear cached gate values */
|
|
49
53
|
clearGateCache(key?: string): void;
|
|
50
54
|
private post;
|
|
51
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,26 +2,28 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Notiformer — Real-time alerts and feature gates for your code.
|
|
4
4
|
*
|
|
5
|
+
* Works in Node.js (backend) and the browser (frontend).
|
|
6
|
+
*
|
|
5
7
|
* @example
|
|
6
8
|
* import { Notiformer } from 'notiformer';
|
|
7
9
|
*
|
|
8
|
-
* const n = new Notiformer({
|
|
9
|
-
* apiKey: 'ntf_live_xxxxxxxxxxxxxxxx', // from app.notiformer.com/projects
|
|
10
|
-
* });
|
|
10
|
+
* const n = new Notiformer({ apiKey: 'ntf_live_...' });
|
|
11
11
|
*
|
|
12
|
+
* // Notify everyone subscribed to the 'payments' channel
|
|
13
|
+
* await n.event({ channel: 'payments', event: 'new_sale', notify: true });
|
|
14
|
+
*
|
|
15
|
+
* // Notify specific people only
|
|
12
16
|
* await n.event({
|
|
13
17
|
* channel: 'payments',
|
|
14
|
-
* event: '
|
|
15
|
-
* description: '$49.00 — john@example.com',
|
|
16
|
-
* icon: '💳',
|
|
18
|
+
* event: 'refund_requested',
|
|
17
19
|
* notify: true,
|
|
20
|
+
* recipients: ['admin@company.com', 'billing@company.com'],
|
|
18
21
|
* });
|
|
19
22
|
*/
|
|
20
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
24
|
exports.Notiformer = void 0;
|
|
22
25
|
const logger_1 = require("./logger");
|
|
23
26
|
const cache_1 = require("./cache");
|
|
24
|
-
// The placeholder key shown in docs — triggers a friendly setup message
|
|
25
27
|
const PLACEHOLDER_KEY = "ntf_live_test";
|
|
26
28
|
const API_URL = "https://api.notiformer.com";
|
|
27
29
|
const DEFAULT_TIMEOUT = 8000;
|
|
@@ -47,7 +49,7 @@ class Notiformer {
|
|
|
47
49
|
"┌─────────────────────────────────────────────────────┐\n" +
|
|
48
50
|
"│ notiformer — setup required │\n" +
|
|
49
51
|
"├─────────────────────────────────────────────────────┤\n" +
|
|
50
|
-
'│ You are using the example
|
|
52
|
+
'│ You are using the example key "ntf_live_test". │\n' +
|
|
51
53
|
"│ Events will not be sent until you use a real key. │\n" +
|
|
52
54
|
"│ │\n" +
|
|
53
55
|
"│ 1. Go to https://app.notiformer.com/projects │\n" +
|
|
@@ -57,14 +59,15 @@ class Notiformer {
|
|
|
57
59
|
"└─────────────────────────────────────────────────────┘\n");
|
|
58
60
|
}
|
|
59
61
|
}
|
|
60
|
-
// ─────────────────────────────────────────────────────────────
|
|
61
|
-
// event()
|
|
62
|
-
// ─────────────────────────────────────────────────────────────
|
|
63
62
|
/**
|
|
64
|
-
* Send an event and optionally
|
|
63
|
+
* Send an event and optionally notify recipients.
|
|
64
|
+
*
|
|
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.
|
|
65
69
|
*
|
|
66
|
-
*
|
|
67
|
-
* Returns null if the call fails (and calls onError if configured).
|
|
70
|
+
* Never throws by default — returns null if the call fails.
|
|
68
71
|
*/
|
|
69
72
|
async event(payload) {
|
|
70
73
|
var _a, _b;
|
|
@@ -72,31 +75,36 @@ class Notiformer {
|
|
|
72
75
|
throw new Error("[notiformer] event.channel is required.");
|
|
73
76
|
if (!payload.event)
|
|
74
77
|
throw new Error("[notiformer] event.event is required.");
|
|
75
|
-
// Placeholder key — log a clear message, do not attempt the call
|
|
76
78
|
if (this.isPlaceholder) {
|
|
77
|
-
console.warn('[notiformer] Event not sent —
|
|
78
|
-
"→ 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");
|
|
79
81
|
return null;
|
|
80
82
|
}
|
|
81
|
-
if (this.silent)
|
|
82
|
-
this.logger.info("Silent mode: event suppressed.");
|
|
83
|
+
if (this.silent)
|
|
83
84
|
return null;
|
|
84
|
-
}
|
|
85
85
|
try {
|
|
86
|
-
const
|
|
86
|
+
const body = {
|
|
87
87
|
channel: payload.channel,
|
|
88
88
|
event: payload.event,
|
|
89
|
-
description: payload.description,
|
|
90
|
-
icon: payload.icon,
|
|
91
|
-
tags: payload.tags,
|
|
92
|
-
value: payload.value,
|
|
93
89
|
notify: (_a = payload.notify) !== null && _a !== void 0 ? _a : true,
|
|
94
|
-
}
|
|
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);
|
|
95
103
|
if (!res.ok) {
|
|
96
|
-
const
|
|
104
|
+
const data = await res
|
|
97
105
|
.json()
|
|
98
106
|
.catch(() => ({ error: `HTTP ${res.status}` }));
|
|
99
|
-
return this.fail(new Error(`[notiformer] ${(_b =
|
|
107
|
+
return this.fail(new Error(`[notiformer] ${(_b = data.error) !== null && _b !== void 0 ? _b : res.statusText}`));
|
|
100
108
|
}
|
|
101
109
|
return (await res.json());
|
|
102
110
|
}
|
|
@@ -104,14 +112,10 @@ class Notiformer {
|
|
|
104
112
|
return this.fail(this.friendlyNetworkError(err));
|
|
105
113
|
}
|
|
106
114
|
}
|
|
107
|
-
// ─────────────────────────────────────────────────────────────
|
|
108
|
-
// gate()
|
|
109
|
-
// ─────────────────────────────────────────────────────────────
|
|
110
115
|
/**
|
|
111
116
|
* Check whether a feature gate is enabled.
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
* Returns fallback (false) if the call fails.
|
|
117
|
+
* Results are cached locally for 30 seconds by default.
|
|
118
|
+
* Returns false if the call fails.
|
|
115
119
|
*/
|
|
116
120
|
async gate(key, options = {}) {
|
|
117
121
|
var _a, _b;
|
|
@@ -136,23 +140,15 @@ class Notiformer {
|
|
|
136
140
|
return fallback;
|
|
137
141
|
}
|
|
138
142
|
}
|
|
139
|
-
/** Full gate result with metadata */
|
|
140
143
|
async gateDetails(key, options = {}) {
|
|
141
144
|
const enabled = await this.gate(key, options);
|
|
142
145
|
return { key, enabled, cached: false, fetchedAt: new Date().toISOString() };
|
|
143
146
|
}
|
|
144
|
-
/** Clear cached gate values */
|
|
145
147
|
clearGateCache(key) {
|
|
146
148
|
key ? this.gateCache.delete(key) : this.gateCache.clear();
|
|
147
149
|
}
|
|
148
|
-
// ─────────────────────────────────────────────────────────────
|
|
149
|
-
// Private
|
|
150
|
-
// ─────────────────────────────────────────────────────────────
|
|
151
150
|
async post(path, body) {
|
|
152
|
-
return this.request(path, {
|
|
153
|
-
method: "POST",
|
|
154
|
-
body: JSON.stringify(body),
|
|
155
|
-
});
|
|
151
|
+
return this.request(path, { method: "POST", body: JSON.stringify(body) });
|
|
156
152
|
}
|
|
157
153
|
async get(path) {
|
|
158
154
|
return this.request(path, { method: "GET" });
|
|
@@ -168,7 +164,7 @@ class Notiformer {
|
|
|
168
164
|
headers: {
|
|
169
165
|
"Content-Type": "application/json",
|
|
170
166
|
Authorization: `Bearer ${this.apiKey}`,
|
|
171
|
-
"X-SDK-Version": "1.0.
|
|
167
|
+
"X-SDK-Version": "1.0.4",
|
|
172
168
|
...((_a = init.headers) !== null && _a !== void 0 ? _a : {}),
|
|
173
169
|
},
|
|
174
170
|
});
|
|
@@ -188,14 +184,13 @@ class Notiformer {
|
|
|
188
184
|
friendlyNetworkError(err) {
|
|
189
185
|
const msg = err instanceof Error ? err.message.toLowerCase() : "";
|
|
190
186
|
if (msg.includes("aborted") || msg.includes("timeout")) {
|
|
191
|
-
return new Error(`[notiformer] Request timed out after ${this.timeout / 1000}s
|
|
192
|
-
"Check your internet connection or try again later.");
|
|
187
|
+
return new Error(`[notiformer] Request timed out after ${this.timeout / 1000}s.`);
|
|
193
188
|
}
|
|
194
189
|
if (msg.includes("failed to fetch") ||
|
|
195
190
|
msg.includes("enotfound") ||
|
|
196
191
|
msg.includes("network")) {
|
|
197
192
|
return new Error("[notiformer] Cannot reach the Notiformer API.\n" +
|
|
198
|
-
"Check your
|
|
193
|
+
"Check your connection. If the issue persists: https://status.notiformer.com");
|
|
199
194
|
}
|
|
200
195
|
return err instanceof Error ? err : new Error(String(err));
|
|
201
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,iBAAS,EAAE,CAAC;QAEjC,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;YACvB,OAAO,CAAC,IAAI,CACV,IAAI;gBACF,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AI,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":""}
|