@betternotify/zapier 0.0.2-alpha.0
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/LICENSE +21 -0
- package/dist/index.d.ts +188 -0
- package/dist/index.js +2651 -0
- package/package.json +46 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Better-Notify contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import * as _betternotify_core0 from "@betternotify/core";
|
|
2
|
+
import { LoggerLike, Transport as Transport$1 } from "@betternotify/core";
|
|
3
|
+
import { HttpClientBehaviorOptions, MockTransport } from "@betternotify/core/transports";
|
|
4
|
+
import * as _betternotify_email0 from "@betternotify/email";
|
|
5
|
+
|
|
6
|
+
//#region src/types.d.ts
|
|
7
|
+
type RenderedZapier = {
|
|
8
|
+
event: string;
|
|
9
|
+
data: Record<string, unknown>;
|
|
10
|
+
meta?: Record<string, string>;
|
|
11
|
+
webhookUrl?: string;
|
|
12
|
+
};
|
|
13
|
+
type ZapierSendArgs<TInput = unknown> = {
|
|
14
|
+
input: TInput;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Wire format for the Zapier channel webhook POST body.
|
|
18
|
+
*
|
|
19
|
+
* The payload is intentionally semi-opinionated: envelope fields (`event`, `route`,
|
|
20
|
+
* `messageId`, `timestamp`) are auto-injected so Zapier users always have stable,
|
|
21
|
+
* consistent top-level fields to filter and branch on — without requiring every
|
|
22
|
+
* route to redeclare them. The `data` field is fully user-defined (whatever the
|
|
23
|
+
* `.data()` slot resolver returns), keeping business payloads flexible. Optional
|
|
24
|
+
* `meta` provides a filtering namespace separate from `data` so automation routing
|
|
25
|
+
* logic doesn't couple to domain models.
|
|
26
|
+
*/
|
|
27
|
+
type ZapierWebhookPayload = {
|
|
28
|
+
event: string;
|
|
29
|
+
route: string;
|
|
30
|
+
messageId: string;
|
|
31
|
+
timestamp: string;
|
|
32
|
+
data: Record<string, unknown>;
|
|
33
|
+
meta?: Record<string, string>;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Wire format for the Zapier email transport POST body.
|
|
37
|
+
*
|
|
38
|
+
* Mirrors `RenderedMessage` fields as flat, individually-addressable JSON so Zapier
|
|
39
|
+
* users can map each field (subject, html, to[0].email, etc.) to downstream actions
|
|
40
|
+
* without parsing. Addresses are normalized to `{ name?, email }` objects rather than
|
|
41
|
+
* RFC 5322 strings for the same reason. Envelope fields (`type`, `route`, `messageId`,
|
|
42
|
+
* `timestamp`) are injected for consistent filtering across both channel and email
|
|
43
|
+
* payloads.
|
|
44
|
+
*/
|
|
45
|
+
type ZapierEmailPayload = {
|
|
46
|
+
type: 'email';
|
|
47
|
+
route: string;
|
|
48
|
+
messageId: string;
|
|
49
|
+
timestamp: string;
|
|
50
|
+
from: {
|
|
51
|
+
name?: string;
|
|
52
|
+
email: string;
|
|
53
|
+
} | null;
|
|
54
|
+
to: Array<{
|
|
55
|
+
name?: string;
|
|
56
|
+
email: string;
|
|
57
|
+
}>;
|
|
58
|
+
cc: Array<{
|
|
59
|
+
name?: string;
|
|
60
|
+
email: string;
|
|
61
|
+
}>;
|
|
62
|
+
bcc: Array<{
|
|
63
|
+
name?: string;
|
|
64
|
+
email: string;
|
|
65
|
+
}>;
|
|
66
|
+
replyTo: {
|
|
67
|
+
name?: string;
|
|
68
|
+
email: string;
|
|
69
|
+
} | null;
|
|
70
|
+
subject: string;
|
|
71
|
+
html: string;
|
|
72
|
+
text: string | null;
|
|
73
|
+
headers: Record<string, string>;
|
|
74
|
+
tags: Record<string, string | number | boolean>;
|
|
75
|
+
attachments: Array<{
|
|
76
|
+
filename: string;
|
|
77
|
+
content: string;
|
|
78
|
+
contentType?: string;
|
|
79
|
+
}>;
|
|
80
|
+
};
|
|
81
|
+
//#endregion
|
|
82
|
+
//#region src/channel.d.ts
|
|
83
|
+
/** Static event name or resolver. Constrained to `TEvent` when the channel is generic. */
|
|
84
|
+
type EventResolver<TInput, TEvent extends string = string> = TEvent | ((args: {
|
|
85
|
+
input: TInput;
|
|
86
|
+
ctx: unknown;
|
|
87
|
+
}) => TEvent);
|
|
88
|
+
/** Static object or resolver returning the webhook data payload. */
|
|
89
|
+
type DataResolver<TInput> = Record<string, unknown> | ((args: {
|
|
90
|
+
input: TInput;
|
|
91
|
+
ctx: unknown;
|
|
92
|
+
}) => Record<string, unknown>);
|
|
93
|
+
/** Static object or resolver returning envelope metadata for filtering. */
|
|
94
|
+
type MetaResolver<TInput> = Record<string, string> | ((args: {
|
|
95
|
+
input: TInput;
|
|
96
|
+
ctx: unknown;
|
|
97
|
+
}) => Record<string, string>);
|
|
98
|
+
/**
|
|
99
|
+
* Zapier notification channel with event, data, meta, and webhookUrl slots.
|
|
100
|
+
*
|
|
101
|
+
* Pass a string union generic to constrain allowed event names:
|
|
102
|
+
* ```ts
|
|
103
|
+
* const zapier = zapierChannel<'order.created' | 'payment.failed'>();
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
declare const zapierChannel: <TEvent extends string = string>() => _betternotify_core0.Channel<"zapier", _betternotify_core0.ChannelBuilder<unknown, {
|
|
107
|
+
event: TEvent;
|
|
108
|
+
data: Record<string, unknown>;
|
|
109
|
+
meta: Record<string, string>;
|
|
110
|
+
webhookUrl: string;
|
|
111
|
+
}, {
|
|
112
|
+
event: _betternotify_core0.SlotConfig<"resolver"> & {
|
|
113
|
+
required: true;
|
|
114
|
+
__value?: TEvent | undefined;
|
|
115
|
+
optional: () => _betternotify_core0.SlotConfig<"resolver"> & {
|
|
116
|
+
required: false;
|
|
117
|
+
__value?: TEvent | undefined;
|
|
118
|
+
optional: /*elided*/any;
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
data: _betternotify_core0.SlotConfig<"resolver"> & {
|
|
122
|
+
required: true;
|
|
123
|
+
__value?: Record<string, unknown> | undefined;
|
|
124
|
+
optional: () => _betternotify_core0.SlotConfig<"resolver"> & {
|
|
125
|
+
required: false;
|
|
126
|
+
__value?: Record<string, unknown> | undefined;
|
|
127
|
+
optional: /*elided*/any;
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
meta: _betternotify_core0.SlotConfig<"resolver"> & {
|
|
131
|
+
required: false;
|
|
132
|
+
__value?: Record<string, string> | undefined;
|
|
133
|
+
optional: () => _betternotify_core0.SlotConfig<"resolver"> & /*elided*/any;
|
|
134
|
+
};
|
|
135
|
+
webhookUrl: _betternotify_core0.SlotConfig<"resolver"> & {
|
|
136
|
+
required: false;
|
|
137
|
+
__value?: string | undefined;
|
|
138
|
+
optional: () => _betternotify_core0.SlotConfig<"resolver"> & /*elided*/any;
|
|
139
|
+
};
|
|
140
|
+
}, Omit<{
|
|
141
|
+
input: unknown;
|
|
142
|
+
}, "input">, RenderedZapier>, {
|
|
143
|
+
input: unknown;
|
|
144
|
+
}, RenderedZapier, _betternotify_core0.Transport<RenderedZapier, unknown>>;
|
|
145
|
+
//#endregion
|
|
146
|
+
//#region src/transports/types.d.ts
|
|
147
|
+
type ZapierChannelTransportData = {
|
|
148
|
+
status: number;
|
|
149
|
+
raw: unknown;
|
|
150
|
+
};
|
|
151
|
+
type Transport = Transport$1<RenderedZapier, ZapierChannelTransportData>;
|
|
152
|
+
//#endregion
|
|
153
|
+
//#region src/transports/channel-transport.types.d.ts
|
|
154
|
+
type ZapierChannelTransportOptions = {
|
|
155
|
+
webhookUrl: string;
|
|
156
|
+
timeoutMs?: number;
|
|
157
|
+
logger?: LoggerLike;
|
|
158
|
+
http?: HttpClientBehaviorOptions;
|
|
159
|
+
};
|
|
160
|
+
//#endregion
|
|
161
|
+
//#region src/transports/channel-transport.d.ts
|
|
162
|
+
/** Zapier channel transport — posts structured webhook payloads to Zapier catch hooks. */
|
|
163
|
+
declare const zapierChannelTransport: (opts: ZapierChannelTransportOptions) => Transport;
|
|
164
|
+
//#endregion
|
|
165
|
+
//#region src/transports/zapier.types.d.ts
|
|
166
|
+
type ZapierTransportOptions = {
|
|
167
|
+
webhookUrl: string;
|
|
168
|
+
timeoutMs?: number;
|
|
169
|
+
logger?: LoggerLike;
|
|
170
|
+
http?: HttpClientBehaviorOptions;
|
|
171
|
+
};
|
|
172
|
+
//#endregion
|
|
173
|
+
//#region src/transports/zapier.d.ts
|
|
174
|
+
/** Email transport that posts rendered messages to a Zapier catch hook webhook. */
|
|
175
|
+
declare const zapierTransport: (opts: ZapierTransportOptions) => _betternotify_email0.Transport;
|
|
176
|
+
//#endregion
|
|
177
|
+
//#region src/transports/mock.d.ts
|
|
178
|
+
type MockZapierTransport = MockTransport<RenderedZapier, ZapierChannelTransportData> & {
|
|
179
|
+
readonly payloads: ReadonlyArray<RenderedZapier & {
|
|
180
|
+
id: string;
|
|
181
|
+
}>;
|
|
182
|
+
};
|
|
183
|
+
declare const mockZapierTransport: () => MockZapierTransport;
|
|
184
|
+
//#endregion
|
|
185
|
+
//#region src/is-retriable.d.ts
|
|
186
|
+
declare const isZapierRetriable: (err: unknown) => boolean;
|
|
187
|
+
//#endregion
|
|
188
|
+
export { type DataResolver, type EventResolver, type MetaResolver, type MockZapierTransport, type RenderedZapier, type Transport, type ZapierChannelTransportData, type ZapierChannelTransportOptions, type ZapierEmailPayload, type ZapierSendArgs, type ZapierTransportOptions, type ZapierWebhookPayload, isZapierRetriable, mockZapierTransport, zapierChannel, zapierChannelTransport, zapierTransport };
|