@postshiba/node 0.0.0-stage → 0.1.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/CHANGELOG.md +5 -0
- package/LICENSE +21 -0
- package/README.md +306 -2
- package/dist/index.d.ts +125 -0
- package/dist/index.js +184 -0
- package/dist/nest.d.ts +25 -0
- package/dist/nest.js +118 -0
- package/package.json +59 -4
package/CHANGELOG.md
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 PostShiba
|
|
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/README.md
CHANGED
|
@@ -1,3 +1,307 @@
|
|
|
1
|
-
#
|
|
1
|
+
# PostShiba
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> [!NOTE]
|
|
4
|
+
> [PostShiba skills](https://github.com/postshiba/postshiba-skills) connect agents to MCP for first send, domains, inboxes, and sandbox mail.
|
|
5
|
+
|
|
6
|
+
PostShiba API client for Node.js.
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```sh
|
|
11
|
+
npm install @postshiba/node
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
`npm install postshiba` is the same client.
|
|
15
|
+
|
|
16
|
+
Node 18 or later. The client uses `fetch`. Open pull requests on [postshiba/sdks](https://github.com/postshiba/sdks).
|
|
17
|
+
|
|
18
|
+
## How It Works
|
|
19
|
+
|
|
20
|
+
`PostShiba` is a thin HTTPS client. Pass a platform application token. Team-scoped routes need `teamId` on the constructor. `GET /users/me` does not return one, so the client does not guess.
|
|
21
|
+
|
|
22
|
+
Send mail with `emails.send`. Nest services inject the same client and call that method.
|
|
23
|
+
|
|
24
|
+
## Send an email
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
import { PostShiba } from "@postshiba/node"
|
|
28
|
+
|
|
29
|
+
const postshiba = new PostShiba(process.env.POSTSHIBA_API_KEY, { teamId: "KjkAJW" })
|
|
30
|
+
|
|
31
|
+
await postshiba.emails.send({
|
|
32
|
+
from: "hello@mail.example.com",
|
|
33
|
+
to: ["you@example.com"],
|
|
34
|
+
subject: "PostShiba test",
|
|
35
|
+
text: "hello from PostShiba",
|
|
36
|
+
html: "<p>hello from PostShiba</p>",
|
|
37
|
+
})
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Pass `clusterId` to send `X-Capsule-Cluster-Id`. The path stays `POST /api/v1/emails`.
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
await postshiba.emails.send(body, { clusterId: "NmQpXr" })
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Cluster send can set `sandbox` and send `Idempotency-Key`:
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
await postshiba.emails.sendOnCluster("NmQpXr", body, {
|
|
50
|
+
sandbox: true,
|
|
51
|
+
idempotencyKey: "ikey-1",
|
|
52
|
+
})
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## NestJS
|
|
56
|
+
|
|
57
|
+
The Nest entry is a module and an injectable token, not a mailer. Import `@postshiba/node` without Nest. Import `@postshiba/node/nest` only in Nest apps.
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
import { Inject, Injectable, Module } from "@nestjs/common"
|
|
61
|
+
import { POSTSHIBA, PostShibaModule, sendMail } from "@postshiba/node/nest"
|
|
62
|
+
import type { PostShiba } from "@postshiba/node"
|
|
63
|
+
|
|
64
|
+
@Module({
|
|
65
|
+
imports: [
|
|
66
|
+
PostShibaModule.register({
|
|
67
|
+
apiKey: process.env.POSTSHIBA_API_KEY!,
|
|
68
|
+
teamId: "KjkAJW",
|
|
69
|
+
}),
|
|
70
|
+
],
|
|
71
|
+
})
|
|
72
|
+
export class AppModule {}
|
|
73
|
+
|
|
74
|
+
@Injectable()
|
|
75
|
+
export class MailService {
|
|
76
|
+
constructor(@Inject(POSTSHIBA) private readonly postshiba: PostShiba) {}
|
|
77
|
+
|
|
78
|
+
sendWelcome() {
|
|
79
|
+
return sendMail(this.postshiba, {
|
|
80
|
+
from: "hello@mail.example.com",
|
|
81
|
+
to: "you@example.com",
|
|
82
|
+
subject: "Welcome",
|
|
83
|
+
text: "hello",
|
|
84
|
+
html: "<p>hello</p>",
|
|
85
|
+
})
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
`sendMail` maps `to`, `from`, `subject`, `html`, `text`, and `attachments` onto `emails.send`. It does not pass a cluster id. Call `this.postshiba.emails.send(body, { clusterId: "NmQpXr" })` to pin a cluster.
|
|
91
|
+
|
|
92
|
+
## API
|
|
93
|
+
|
|
94
|
+
Override `baseUrl` when you are not on production.
|
|
95
|
+
|
|
96
|
+
```ts
|
|
97
|
+
new PostShiba(process.env.POSTSHIBA_API_KEY, {
|
|
98
|
+
teamId: "KjkAJW",
|
|
99
|
+
baseUrl: "https://app.postshiba.com",
|
|
100
|
+
})
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Users
|
|
104
|
+
|
|
105
|
+
```ts
|
|
106
|
+
await postshiba.users.me()
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Emails
|
|
110
|
+
|
|
111
|
+
```ts
|
|
112
|
+
await postshiba.emails.send(body)
|
|
113
|
+
await postshiba.emails.send(body, { clusterId: "NmQpXr" })
|
|
114
|
+
await postshiba.emails.sendOnCluster("NmQpXr", body, { sandbox: true })
|
|
115
|
+
await postshiba.emails.send({
|
|
116
|
+
to: ["you@example.com"],
|
|
117
|
+
template: { id: "welcome", variables: { name: "Ada" } },
|
|
118
|
+
})
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Clusters
|
|
122
|
+
|
|
123
|
+
```ts
|
|
124
|
+
await postshiba.clusters.list()
|
|
125
|
+
await postshiba.clusters.get("NmQpXr")
|
|
126
|
+
await postshiba.clusters.create({ cluster: { name: "edge", size: "small", region: "manual", plan: "nano" } })
|
|
127
|
+
await postshiba.clusters.update("NmQpXr", { cluster: { plan: "small" } })
|
|
128
|
+
await postshiba.clusters.suspend("NmQpXr")
|
|
129
|
+
await postshiba.clusters.resume("NmQpXr")
|
|
130
|
+
await postshiba.clusters.delete("NmQpXr")
|
|
131
|
+
await postshiba.clusters.boost("NmQpXr", { sku: "small_to_large" })
|
|
132
|
+
await postshiba.clusters.extendBoost("NmQpXr", { idempotency_key: "extend-1" })
|
|
133
|
+
await postshiba.clusters.cancelBoost("NmQpXr")
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Network
|
|
137
|
+
|
|
138
|
+
```ts
|
|
139
|
+
await postshiba.network.list()
|
|
140
|
+
await postshiba.network.create({ ip_address_id: "IpQwEr", cluster_id: "NmQpXr" })
|
|
141
|
+
await postshiba.network.assign({ ip_address_id: "IpQwEr", cluster_id: "NmQpXr" })
|
|
142
|
+
await postshiba.network.unassign({ ip_address_id: "IpQwEr", cluster_id: "NmQpXr" })
|
|
143
|
+
await postshiba.network.switch({ ip_address_id: "IpQwEr", cluster_id: "NmQpXr" })
|
|
144
|
+
await postshiba.network.release({ ip_address_id: "IpQwEr" })
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### Sending domains
|
|
148
|
+
|
|
149
|
+
```ts
|
|
150
|
+
await postshiba.sendingDomains.list()
|
|
151
|
+
await postshiba.sendingDomains.get("HsVtYk")
|
|
152
|
+
await postshiba.sendingDomains.create({ sending_domain: { name: "mail.example.com", tenant_id: "WbLcFd" } })
|
|
153
|
+
await postshiba.sendingDomains.update("HsVtYk", { sending_domain: { dkim_selector: "s1", dkim_manual: true } })
|
|
154
|
+
await postshiba.sendingDomains.refresh("HsVtYk")
|
|
155
|
+
await postshiba.sendingDomains.verify("HsVtYk")
|
|
156
|
+
await postshiba.sendingDomains.suspend("HsVtYk")
|
|
157
|
+
await postshiba.sendingDomains.resume("HsVtYk")
|
|
158
|
+
await postshiba.sendingDomains.makePrimary("HsVtYk")
|
|
159
|
+
await postshiba.sendingDomains.delete("HsVtYk")
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### Tenants
|
|
163
|
+
|
|
164
|
+
```ts
|
|
165
|
+
await postshiba.tenants.list()
|
|
166
|
+
await postshiba.tenants.get("WbLcFd")
|
|
167
|
+
await postshiba.tenants.create({ tenant: { name: "Acme Florist" } })
|
|
168
|
+
await postshiba.tenants.delete("WbLcFd")
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Inboxes
|
|
172
|
+
|
|
173
|
+
```ts
|
|
174
|
+
await postshiba.inboxes.list()
|
|
175
|
+
await postshiba.inboxes.get("PqRzMn")
|
|
176
|
+
await postshiba.inboxes.create({
|
|
177
|
+
inbox: {
|
|
178
|
+
name: "agent",
|
|
179
|
+
webhook_url: "https://hooks.example.com/mail",
|
|
180
|
+
host: "inbound.example.com",
|
|
181
|
+
forward_to: "you@example.com",
|
|
182
|
+
},
|
|
183
|
+
})
|
|
184
|
+
await postshiba.inboxes.verify("PqRzMn")
|
|
185
|
+
await postshiba.inboxes.delete("PqRzMn")
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### Messages
|
|
189
|
+
|
|
190
|
+
```ts
|
|
191
|
+
await postshiba.messages.list("PqRzMn")
|
|
192
|
+
await postshiba.messages.get("PqRzMn", "GxTyVu")
|
|
193
|
+
await postshiba.messages.downloadAttachment("PqRzMn", "GxTyVu", 1)
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### Events
|
|
197
|
+
|
|
198
|
+
```ts
|
|
199
|
+
await postshiba.events.listTeam()
|
|
200
|
+
await postshiba.events.list("NmQpXr")
|
|
201
|
+
await postshiba.events.get("JkLmNp")
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### SMTP credentials
|
|
205
|
+
|
|
206
|
+
```ts
|
|
207
|
+
await postshiba.smtpCredentials.create("NmQpXr", { smtp_credential: { tenant_id: "WbLcFd" } })
|
|
208
|
+
await postshiba.smtpCredentials.delete("NmQpXr", "RvWsXq")
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
Create returns `password`. Delete does not.
|
|
212
|
+
|
|
213
|
+
### Webhooks
|
|
214
|
+
|
|
215
|
+
```ts
|
|
216
|
+
await postshiba.webhooks.list()
|
|
217
|
+
await postshiba.webhooks.get("CdFgHj")
|
|
218
|
+
await postshiba.webhooks.create({
|
|
219
|
+
webhook_endpoint: {
|
|
220
|
+
url: "https://hooks.example.com/capsule",
|
|
221
|
+
event_types: ["delivered", "bounce"],
|
|
222
|
+
cluster_id: "NmQpXr",
|
|
223
|
+
},
|
|
224
|
+
})
|
|
225
|
+
await postshiba.webhooks.update("CdFgHj", {
|
|
226
|
+
webhook_endpoint: { enabled: false, event_types: ["delivered", "bounce"] },
|
|
227
|
+
})
|
|
228
|
+
await postshiba.webhooks.delete("CdFgHj")
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
List and update omit `secret`. Get and create return it.
|
|
232
|
+
|
|
233
|
+
### Templates
|
|
234
|
+
|
|
235
|
+
```ts
|
|
236
|
+
await postshiba.templates.list()
|
|
237
|
+
await postshiba.templates.get("welcome")
|
|
238
|
+
await postshiba.templates.create({
|
|
239
|
+
email_template: {
|
|
240
|
+
name: "Welcome",
|
|
241
|
+
alias: "welcome",
|
|
242
|
+
subject: "Hi {{ name }}",
|
|
243
|
+
html: "<p>Hi {{ name }}</p>",
|
|
244
|
+
},
|
|
245
|
+
})
|
|
246
|
+
await postshiba.templates.update("TpLmQr", { email_template: { subject: "Welcome, {{ name }}" } })
|
|
247
|
+
await postshiba.templates.publish("TpLmQr")
|
|
248
|
+
await postshiba.templates.duplicate("TpLmQr")
|
|
249
|
+
await postshiba.templates.delete("TpLmQr")
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
Send uses the published snapshot. `get` and member routes accept the public id or the alias.
|
|
253
|
+
|
|
254
|
+
### Suppressions
|
|
255
|
+
|
|
256
|
+
```ts
|
|
257
|
+
await postshiba.suppressions.list()
|
|
258
|
+
await postshiba.suppressions.create({ suppression: { email: "blocked@example.com", tenant_id: "WbLcFd" } })
|
|
259
|
+
await postshiba.suppressions.import({ emails: ["blocked@example.com", "old@example.com"], tenant_id: "WbLcFd" })
|
|
260
|
+
await postshiba.suppressions.delete("YtReWq")
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
### Firewall
|
|
264
|
+
|
|
265
|
+
```ts
|
|
266
|
+
await postshiba.firewall.get()
|
|
267
|
+
await postshiba.firewall.update({ firewall: { enabled_checks: ["temp_providers", "plus_addressing"] } })
|
|
268
|
+
await postshiba.firewall.addEntry({ firewall_entry: { list: "deny", value: "mailinator.com" } })
|
|
269
|
+
await postshiba.firewall.deleteEntry("BnMkLo")
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
## Verify webhooks
|
|
273
|
+
|
|
274
|
+
HMAC-SHA256 of `{timestamp}.{rawBody}` against `X-Capsule-Signature`. A `sha256=` prefix is stripped.
|
|
275
|
+
|
|
276
|
+
```ts
|
|
277
|
+
const ok = postshiba.webhooks.verify(rawBody, timestamp, signature, secret)
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
## Errors and throttling
|
|
281
|
+
|
|
282
|
+
Non-2xx responses throw `PostShibaError` with `error`, `field`, and `message` from the JSON body.
|
|
283
|
+
|
|
284
|
+
```ts
|
|
285
|
+
import { PostShibaError } from "@postshiba/node"
|
|
286
|
+
|
|
287
|
+
try {
|
|
288
|
+
await postshiba.emails.send(body)
|
|
289
|
+
} catch (err) {
|
|
290
|
+
if (err instanceof PostShibaError) {
|
|
291
|
+
console.error(err.error, err.field, err.message)
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
A `429` response with `error` `throttled` means the cluster hit its hourly send limit. Do not retry that send immediately. Immediate retries hit the same cap. Wait until the next hour. The client does not delay for you. In a queued job, catch `PostShibaError` and check `err.error === "throttled"` before sending again.
|
|
297
|
+
|
|
298
|
+
Missing `teamId` on a team-scoped call throws before any request.
|
|
299
|
+
|
|
300
|
+
## Contributing
|
|
301
|
+
|
|
302
|
+
```sh
|
|
303
|
+
npm install
|
|
304
|
+
npm test
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
Tests mock HTTP and load fixtures from `../../fixtures/catalog`. They do not call production.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
export type Id = string;
|
|
2
|
+
export type Json = Record<string, unknown>;
|
|
3
|
+
export type PostShibaOptions = {
|
|
4
|
+
baseUrl?: string;
|
|
5
|
+
teamId?: Id;
|
|
6
|
+
};
|
|
7
|
+
export type SendOptions = {
|
|
8
|
+
clusterId?: Id;
|
|
9
|
+
};
|
|
10
|
+
export type ClusterSendOptions = {
|
|
11
|
+
idempotencyKey?: string;
|
|
12
|
+
sandbox?: boolean;
|
|
13
|
+
};
|
|
14
|
+
export declare class PostShibaError extends Error {
|
|
15
|
+
readonly error: string;
|
|
16
|
+
readonly field: string | null;
|
|
17
|
+
constructor(attrs: {
|
|
18
|
+
error?: string;
|
|
19
|
+
field?: string | null;
|
|
20
|
+
message?: string;
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
export declare class PostShiba {
|
|
24
|
+
readonly apiKey: string;
|
|
25
|
+
readonly baseUrl: string;
|
|
26
|
+
readonly teamId?: Id;
|
|
27
|
+
constructor(apiKey: string, options?: PostShibaOptions);
|
|
28
|
+
private requireTeamId;
|
|
29
|
+
private request;
|
|
30
|
+
readonly users: {
|
|
31
|
+
me: () => Promise<unknown>;
|
|
32
|
+
};
|
|
33
|
+
readonly emails: {
|
|
34
|
+
send: (body: Json, options?: SendOptions) => Promise<unknown>;
|
|
35
|
+
sendOnCluster: (clusterId: Id, body: Json, options?: ClusterSendOptions) => Promise<unknown>;
|
|
36
|
+
};
|
|
37
|
+
readonly clusters: {
|
|
38
|
+
list: () => Promise<unknown>;
|
|
39
|
+
get: (id: Id) => Promise<unknown>;
|
|
40
|
+
create: (body: Json) => Promise<unknown>;
|
|
41
|
+
update: (id: Id, body: Json) => Promise<unknown>;
|
|
42
|
+
suspend: (id: Id) => Promise<unknown>;
|
|
43
|
+
resume: (id: Id) => Promise<unknown>;
|
|
44
|
+
delete: (id: Id) => Promise<unknown>;
|
|
45
|
+
boost: (id: Id, body: Json) => Promise<unknown>;
|
|
46
|
+
extendBoost: (id: Id, body: Json) => Promise<unknown>;
|
|
47
|
+
cancelBoost: (id: Id) => Promise<unknown>;
|
|
48
|
+
};
|
|
49
|
+
readonly network: {
|
|
50
|
+
list: () => Promise<unknown>;
|
|
51
|
+
create: (body: Json) => Promise<unknown>;
|
|
52
|
+
assign: (body: Json) => Promise<unknown>;
|
|
53
|
+
unassign: (body: Json) => Promise<unknown>;
|
|
54
|
+
switch: (body: Json) => Promise<unknown>;
|
|
55
|
+
release: (body: Json) => Promise<unknown>;
|
|
56
|
+
};
|
|
57
|
+
readonly sendingDomains: {
|
|
58
|
+
list: () => Promise<unknown>;
|
|
59
|
+
get: (id: Id) => Promise<unknown>;
|
|
60
|
+
create: (body: Json) => Promise<unknown>;
|
|
61
|
+
update: (id: Id, body: Json) => Promise<unknown>;
|
|
62
|
+
refresh: (id: Id) => Promise<unknown>;
|
|
63
|
+
verify: (id: Id) => Promise<unknown>;
|
|
64
|
+
suspend: (id: Id) => Promise<unknown>;
|
|
65
|
+
resume: (id: Id) => Promise<unknown>;
|
|
66
|
+
makePrimary: (id: Id) => Promise<unknown>;
|
|
67
|
+
delete: (id: Id) => Promise<unknown>;
|
|
68
|
+
};
|
|
69
|
+
readonly tenants: {
|
|
70
|
+
list: () => Promise<unknown>;
|
|
71
|
+
get: (id: Id) => Promise<unknown>;
|
|
72
|
+
create: (body: Json) => Promise<unknown>;
|
|
73
|
+
delete: (id: Id) => Promise<unknown>;
|
|
74
|
+
};
|
|
75
|
+
readonly inboxes: {
|
|
76
|
+
list: () => Promise<unknown>;
|
|
77
|
+
get: (id: Id) => Promise<unknown>;
|
|
78
|
+
create: (body: Json) => Promise<unknown>;
|
|
79
|
+
verify: (id: Id) => Promise<unknown>;
|
|
80
|
+
delete: (id: Id) => Promise<unknown>;
|
|
81
|
+
};
|
|
82
|
+
readonly messages: {
|
|
83
|
+
list: (inboxId: Id) => Promise<unknown>;
|
|
84
|
+
get: (inboxId: Id, id: Id) => Promise<unknown>;
|
|
85
|
+
downloadAttachment: (inboxId: Id, id: Id, index: number) => Promise<unknown>;
|
|
86
|
+
};
|
|
87
|
+
readonly events: {
|
|
88
|
+
listTeam: () => Promise<unknown>;
|
|
89
|
+
list: (clusterId: Id) => Promise<unknown>;
|
|
90
|
+
get: (id: Id) => Promise<unknown>;
|
|
91
|
+
};
|
|
92
|
+
readonly smtpCredentials: {
|
|
93
|
+
create: (clusterId: Id, body: Json) => Promise<unknown>;
|
|
94
|
+
delete: (clusterId: Id, id: Id) => Promise<unknown>;
|
|
95
|
+
};
|
|
96
|
+
readonly webhooks: {
|
|
97
|
+
list: () => Promise<unknown>;
|
|
98
|
+
get: (id: Id) => Promise<unknown>;
|
|
99
|
+
create: (body: Json) => Promise<unknown>;
|
|
100
|
+
update: (id: Id, body: Json) => Promise<unknown>;
|
|
101
|
+
delete: (id: Id) => Promise<unknown>;
|
|
102
|
+
verify: (rawBody: string, timestamp: string, signature: string, secret: string) => boolean;
|
|
103
|
+
};
|
|
104
|
+
readonly templates: {
|
|
105
|
+
list: () => Promise<unknown>;
|
|
106
|
+
get: (id: Id) => Promise<unknown>;
|
|
107
|
+
create: (body: Json) => Promise<unknown>;
|
|
108
|
+
update: (id: Id, body: Json) => Promise<unknown>;
|
|
109
|
+
publish: (id: Id) => Promise<unknown>;
|
|
110
|
+
duplicate: (id: Id) => Promise<unknown>;
|
|
111
|
+
delete: (id: Id) => Promise<unknown>;
|
|
112
|
+
};
|
|
113
|
+
readonly suppressions: {
|
|
114
|
+
list: () => Promise<unknown>;
|
|
115
|
+
create: (body: Json) => Promise<unknown>;
|
|
116
|
+
import: (body: Json) => Promise<unknown>;
|
|
117
|
+
delete: (id: Id) => Promise<unknown>;
|
|
118
|
+
};
|
|
119
|
+
readonly firewall: {
|
|
120
|
+
get: () => Promise<unknown>;
|
|
121
|
+
update: (body: Json) => Promise<unknown>;
|
|
122
|
+
addEntry: (body: Json) => Promise<unknown>;
|
|
123
|
+
deleteEntry: (id: Id) => Promise<unknown>;
|
|
124
|
+
};
|
|
125
|
+
}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { createHmac, timingSafeEqual } from "node:crypto";
|
|
2
|
+
export class PostShibaError extends Error {
|
|
3
|
+
error;
|
|
4
|
+
field;
|
|
5
|
+
constructor(attrs) {
|
|
6
|
+
super(attrs.message ?? attrs.error ?? "Request failed");
|
|
7
|
+
this.name = "PostShibaError";
|
|
8
|
+
this.error = attrs.error ?? "error";
|
|
9
|
+
this.field = attrs.field ?? null;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
function parseJson(text) {
|
|
13
|
+
if (!text)
|
|
14
|
+
return {};
|
|
15
|
+
try {
|
|
16
|
+
return JSON.parse(text);
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return text;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function asErrorPayload(value) {
|
|
23
|
+
if (value && typeof value === "object")
|
|
24
|
+
return value;
|
|
25
|
+
return {};
|
|
26
|
+
}
|
|
27
|
+
export class PostShiba {
|
|
28
|
+
apiKey;
|
|
29
|
+
baseUrl;
|
|
30
|
+
teamId;
|
|
31
|
+
constructor(apiKey, options = {}) {
|
|
32
|
+
this.apiKey = apiKey;
|
|
33
|
+
this.baseUrl = (options.baseUrl ?? "https://app.postshiba.com").replace(/\/$/, "");
|
|
34
|
+
this.teamId = options.teamId;
|
|
35
|
+
}
|
|
36
|
+
requireTeamId() {
|
|
37
|
+
if (this.teamId === undefined || this.teamId === null || this.teamId === "") {
|
|
38
|
+
throw new Error("teamId is required");
|
|
39
|
+
}
|
|
40
|
+
return this.teamId;
|
|
41
|
+
}
|
|
42
|
+
async request(method, path, opts = {}) {
|
|
43
|
+
const resolved = opts.team ? `/api/v1/teams/${this.requireTeamId()}${path}` : path;
|
|
44
|
+
const headers = {
|
|
45
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
46
|
+
Accept: "application/json",
|
|
47
|
+
...opts.headers,
|
|
48
|
+
};
|
|
49
|
+
if (opts.body !== undefined)
|
|
50
|
+
headers["Content-Type"] = "application/json";
|
|
51
|
+
const res = await fetch(`${this.baseUrl}${resolved}`, {
|
|
52
|
+
method,
|
|
53
|
+
headers,
|
|
54
|
+
body: opts.body === undefined ? undefined : JSON.stringify(opts.body),
|
|
55
|
+
});
|
|
56
|
+
if (!res.ok) {
|
|
57
|
+
const payload = asErrorPayload(parseJson(await res.text()));
|
|
58
|
+
throw new PostShibaError({
|
|
59
|
+
error: payload.error,
|
|
60
|
+
field: payload.field ?? null,
|
|
61
|
+
message: payload.message,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
if (opts.binary)
|
|
65
|
+
return res.arrayBuffer();
|
|
66
|
+
return parseJson(await res.text());
|
|
67
|
+
}
|
|
68
|
+
users = {
|
|
69
|
+
me: () => this.request("GET", "/api/v1/users/me"),
|
|
70
|
+
};
|
|
71
|
+
emails = {
|
|
72
|
+
send: (body, options = {}) => {
|
|
73
|
+
const headers = {};
|
|
74
|
+
if (options.clusterId !== undefined && options.clusterId !== null && options.clusterId !== "") {
|
|
75
|
+
headers["X-Capsule-Cluster-Id"] = String(options.clusterId);
|
|
76
|
+
}
|
|
77
|
+
return this.request("POST", "/api/v1/emails", { body, headers });
|
|
78
|
+
},
|
|
79
|
+
sendOnCluster: (clusterId, body, options = {}) => {
|
|
80
|
+
const payload = options.sandbox ? { ...body, sandbox: true } : body;
|
|
81
|
+
const headers = {};
|
|
82
|
+
if (options.idempotencyKey)
|
|
83
|
+
headers["Idempotency-Key"] = options.idempotencyKey;
|
|
84
|
+
return this.request("POST", `/clusters/${clusterId}/sends`, { body: payload, headers, team: true });
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
clusters = {
|
|
88
|
+
list: () => this.request("GET", "/clusters", { team: true }),
|
|
89
|
+
get: (id) => this.request("GET", `/api/v1/clusters/${id}`),
|
|
90
|
+
create: (body) => this.request("POST", "/clusters", { body, team: true }),
|
|
91
|
+
update: (id, body) => this.request("PATCH", `/api/v1/clusters/${id}`, { body }),
|
|
92
|
+
suspend: (id) => this.request("POST", `/api/v1/clusters/${id}/suspend`),
|
|
93
|
+
resume: (id) => this.request("POST", `/api/v1/clusters/${id}/resume`),
|
|
94
|
+
delete: (id) => this.request("DELETE", `/api/v1/clusters/${id}`),
|
|
95
|
+
boost: (id, body) => this.request("POST", `/api/v1/clusters/${id}/boost`, { body }),
|
|
96
|
+
extendBoost: (id, body) => this.request("POST", `/api/v1/clusters/${id}/extend_boost`, { body }),
|
|
97
|
+
cancelBoost: (id) => this.request("POST", `/api/v1/clusters/${id}/cancel_boost`),
|
|
98
|
+
};
|
|
99
|
+
network = {
|
|
100
|
+
list: () => this.request("GET", "/network", { team: true }),
|
|
101
|
+
create: (body) => this.request("POST", "/network", { body, team: true }),
|
|
102
|
+
assign: (body) => this.request("POST", "/network/assign", { body, team: true }),
|
|
103
|
+
unassign: (body) => this.request("POST", "/network/unassign", { body, team: true }),
|
|
104
|
+
switch: (body) => this.request("POST", "/network/switch", { body, team: true }),
|
|
105
|
+
release: (body) => this.request("POST", "/network/release", { body, team: true }),
|
|
106
|
+
};
|
|
107
|
+
sendingDomains = {
|
|
108
|
+
list: () => this.request("GET", "/sending_domains", { team: true }),
|
|
109
|
+
get: (id) => this.request("GET", `/api/v1/sending_domains/${id}`),
|
|
110
|
+
create: (body) => this.request("POST", "/sending_domains", { body, team: true }),
|
|
111
|
+
update: (id, body) => this.request("PATCH", `/api/v1/sending_domains/${id}`, { body }),
|
|
112
|
+
refresh: (id) => this.request("POST", `/api/v1/sending_domains/${id}/refresh`),
|
|
113
|
+
verify: (id) => this.request("POST", `/api/v1/sending_domains/${id}/verify`),
|
|
114
|
+
suspend: (id) => this.request("POST", `/api/v1/sending_domains/${id}/suspend`),
|
|
115
|
+
resume: (id) => this.request("POST", `/api/v1/sending_domains/${id}/resume`),
|
|
116
|
+
makePrimary: (id) => this.request("POST", `/api/v1/sending_domains/${id}/make_primary`),
|
|
117
|
+
delete: (id) => this.request("DELETE", `/api/v1/sending_domains/${id}`),
|
|
118
|
+
};
|
|
119
|
+
tenants = {
|
|
120
|
+
list: () => this.request("GET", "/tenants", { team: true }),
|
|
121
|
+
get: (id) => this.request("GET", `/api/v1/tenants/${id}`),
|
|
122
|
+
create: (body) => this.request("POST", "/tenants", { body, team: true }),
|
|
123
|
+
delete: (id) => this.request("DELETE", `/api/v1/tenants/${id}`),
|
|
124
|
+
};
|
|
125
|
+
inboxes = {
|
|
126
|
+
list: () => this.request("GET", "/inboxes", { team: true }),
|
|
127
|
+
get: (id) => this.request("GET", `/api/v1/inboxes/${id}`),
|
|
128
|
+
create: (body) => this.request("POST", "/inboxes", { body, team: true }),
|
|
129
|
+
verify: (id) => this.request("POST", `/api/v1/inboxes/${id}/verify`),
|
|
130
|
+
delete: (id) => this.request("DELETE", `/api/v1/inboxes/${id}`),
|
|
131
|
+
};
|
|
132
|
+
messages = {
|
|
133
|
+
list: (inboxId) => this.request("GET", `/api/v1/inboxes/${inboxId}/inbound_messages`),
|
|
134
|
+
get: (inboxId, id) => this.request("GET", `/api/v1/inboxes/${inboxId}/inbound_messages/${id}`),
|
|
135
|
+
downloadAttachment: (inboxId, id, index) => this.request("GET", `/api/v1/inboxes/${inboxId}/inbound_messages/${id}/attachments/${index}`, { binary: true }),
|
|
136
|
+
};
|
|
137
|
+
events = {
|
|
138
|
+
listTeam: () => this.request("GET", "/message_events", { team: true }),
|
|
139
|
+
list: (clusterId) => this.request("GET", `/clusters/${clusterId}/message_events`, { team: true }),
|
|
140
|
+
get: (id) => this.request("GET", `/api/v1/message_events/${id}`),
|
|
141
|
+
};
|
|
142
|
+
smtpCredentials = {
|
|
143
|
+
create: (clusterId, body) => this.request("POST", `/clusters/${clusterId}/smtp_credentials`, { body, team: true }),
|
|
144
|
+
delete: (clusterId, id) => this.request("DELETE", `/clusters/${clusterId}/smtp_credentials/${id}`, { team: true }),
|
|
145
|
+
};
|
|
146
|
+
webhooks = {
|
|
147
|
+
list: () => this.request("GET", "/webhook_endpoints", { team: true }),
|
|
148
|
+
get: (id) => this.request("GET", `/api/v1/webhook_endpoints/${id}`),
|
|
149
|
+
create: (body) => this.request("POST", "/webhook_endpoints", { body, team: true }),
|
|
150
|
+
update: (id, body) => this.request("PATCH", `/api/v1/webhook_endpoints/${id}`, { body }),
|
|
151
|
+
delete: (id) => this.request("DELETE", `/api/v1/webhook_endpoints/${id}`),
|
|
152
|
+
verify: (rawBody, timestamp, signature, secret) => verifySignature(rawBody, timestamp, signature, secret),
|
|
153
|
+
};
|
|
154
|
+
templates = {
|
|
155
|
+
list: () => this.request("GET", "/templates", { team: true }),
|
|
156
|
+
get: (id) => this.request("GET", `/api/v1/templates/${id}`),
|
|
157
|
+
create: (body) => this.request("POST", "/templates", { body, team: true }),
|
|
158
|
+
update: (id, body) => this.request("PATCH", `/api/v1/templates/${id}`, { body }),
|
|
159
|
+
publish: (id) => this.request("POST", `/api/v1/templates/${id}/publish`),
|
|
160
|
+
duplicate: (id) => this.request("POST", `/api/v1/templates/${id}/duplicate`),
|
|
161
|
+
delete: (id) => this.request("DELETE", `/api/v1/templates/${id}`),
|
|
162
|
+
};
|
|
163
|
+
suppressions = {
|
|
164
|
+
list: () => this.request("GET", "/suppressions", { team: true }),
|
|
165
|
+
create: (body) => this.request("POST", "/suppressions", { body, team: true }),
|
|
166
|
+
import: (body) => this.request("POST", "/suppressions/import", { body, team: true }),
|
|
167
|
+
delete: (id) => this.request("DELETE", `/api/v1/suppressions/${id}`),
|
|
168
|
+
};
|
|
169
|
+
firewall = {
|
|
170
|
+
get: () => this.request("GET", "/firewall", { team: true }),
|
|
171
|
+
update: (body) => this.request("PATCH", "/firewall", { body, team: true }),
|
|
172
|
+
addEntry: (body) => this.request("POST", "/firewall_entries", { body, team: true }),
|
|
173
|
+
deleteEntry: (id) => this.request("DELETE", `/api/v1/firewall_entries/${id}`),
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
function verifySignature(rawBody, timestamp, signature, secret) {
|
|
177
|
+
const given = signature.replace(/^sha256=/, "");
|
|
178
|
+
const expected = createHmac("sha256", secret).update(`${timestamp}.${rawBody}`).digest("hex");
|
|
179
|
+
const a = Buffer.from(expected);
|
|
180
|
+
const b = Buffer.from(given);
|
|
181
|
+
if (a.length !== b.length)
|
|
182
|
+
return false;
|
|
183
|
+
return timingSafeEqual(a, b);
|
|
184
|
+
}
|
package/dist/nest.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { DynamicModule } from "@nestjs/common";
|
|
2
|
+
import { PostShiba } from "./index.js";
|
|
3
|
+
import type { PostShibaOptions } from "./index.js";
|
|
4
|
+
export { PostShiba, PostShibaError } from "./index.js";
|
|
5
|
+
export type { Id, Json, PostShibaOptions } from "./index.js";
|
|
6
|
+
export declare const POSTSHIBA = "POSTSHIBA";
|
|
7
|
+
export type MailFields = {
|
|
8
|
+
to: string | string[];
|
|
9
|
+
from: string;
|
|
10
|
+
subject: string;
|
|
11
|
+
html?: string;
|
|
12
|
+
text?: string;
|
|
13
|
+
attachments?: unknown[];
|
|
14
|
+
cc?: string | string[];
|
|
15
|
+
bcc?: string | string[];
|
|
16
|
+
replyTo?: string;
|
|
17
|
+
headers?: Record<string, string>;
|
|
18
|
+
uniqueArgs?: Record<string, unknown>;
|
|
19
|
+
};
|
|
20
|
+
export declare function sendMail(client: PostShiba, mail: MailFields): Promise<unknown>;
|
|
21
|
+
export declare class PostShibaModule {
|
|
22
|
+
static register(options: {
|
|
23
|
+
apiKey: string;
|
|
24
|
+
} & PostShibaOptions): DynamicModule;
|
|
25
|
+
}
|
package/dist/nest.js
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
2
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
3
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
4
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
5
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
6
|
+
var _, done = false;
|
|
7
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
8
|
+
var context = {};
|
|
9
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
10
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
11
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
12
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
13
|
+
if (kind === "accessor") {
|
|
14
|
+
if (result === void 0) continue;
|
|
15
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
16
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
17
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
18
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
19
|
+
}
|
|
20
|
+
else if (_ = accept(result)) {
|
|
21
|
+
if (kind === "field") initializers.unshift(_);
|
|
22
|
+
else descriptor[key] = _;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
26
|
+
done = true;
|
|
27
|
+
};
|
|
28
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
29
|
+
var useValue = arguments.length > 2;
|
|
30
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
31
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
32
|
+
}
|
|
33
|
+
return useValue ? value : void 0;
|
|
34
|
+
};
|
|
35
|
+
import { Module } from "@nestjs/common";
|
|
36
|
+
import { PostShiba } from "./index.js";
|
|
37
|
+
export { PostShiba, PostShibaError } from "./index.js";
|
|
38
|
+
export const POSTSHIBA = "POSTSHIBA";
|
|
39
|
+
function asList(value) {
|
|
40
|
+
return Array.isArray(value) ? value : [value];
|
|
41
|
+
}
|
|
42
|
+
function uniqueArgsFromHeaders(headers) {
|
|
43
|
+
const key = Object.keys(headers).find((name) => name.toLowerCase() === "x-capsule-unique-args");
|
|
44
|
+
if (!key) {
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
const raw = headers[key];
|
|
48
|
+
delete headers[key];
|
|
49
|
+
try {
|
|
50
|
+
const parsed = JSON.parse(raw);
|
|
51
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
52
|
+
return parsed;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
export function sendMail(client, mail) {
|
|
61
|
+
const body = {
|
|
62
|
+
from: mail.from,
|
|
63
|
+
to: asList(mail.to),
|
|
64
|
+
subject: mail.subject,
|
|
65
|
+
};
|
|
66
|
+
if (mail.html !== undefined)
|
|
67
|
+
body.html = mail.html;
|
|
68
|
+
if (mail.text !== undefined)
|
|
69
|
+
body.text = mail.text;
|
|
70
|
+
if (mail.attachments !== undefined)
|
|
71
|
+
body.attachments = mail.attachments;
|
|
72
|
+
if (mail.cc !== undefined)
|
|
73
|
+
body.cc = asList(mail.cc);
|
|
74
|
+
if (mail.bcc !== undefined)
|
|
75
|
+
body.bcc = asList(mail.bcc);
|
|
76
|
+
if (mail.replyTo)
|
|
77
|
+
body.reply_to = mail.replyTo;
|
|
78
|
+
const headers = mail.headers ? { ...mail.headers } : {};
|
|
79
|
+
const fromHeader = uniqueArgsFromHeaders(headers);
|
|
80
|
+
if (Object.keys(headers).length > 0)
|
|
81
|
+
body.headers = headers;
|
|
82
|
+
if (fromHeader)
|
|
83
|
+
body.unique_args = fromHeader;
|
|
84
|
+
if (mail.uniqueArgs && Object.keys(mail.uniqueArgs).length > 0) {
|
|
85
|
+
body.unique_args = mail.uniqueArgs;
|
|
86
|
+
}
|
|
87
|
+
return client.emails.send(body);
|
|
88
|
+
}
|
|
89
|
+
let PostShibaModule = (() => {
|
|
90
|
+
let _classDecorators = [Module({})];
|
|
91
|
+
let _classDescriptor;
|
|
92
|
+
let _classExtraInitializers = [];
|
|
93
|
+
let _classThis;
|
|
94
|
+
var PostShibaModule = class {
|
|
95
|
+
static { _classThis = this; }
|
|
96
|
+
static {
|
|
97
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
98
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
99
|
+
PostShibaModule = _classThis = _classDescriptor.value;
|
|
100
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
101
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
102
|
+
}
|
|
103
|
+
static register(options) {
|
|
104
|
+
return {
|
|
105
|
+
module: PostShibaModule,
|
|
106
|
+
providers: [
|
|
107
|
+
{
|
|
108
|
+
provide: POSTSHIBA,
|
|
109
|
+
useValue: new PostShiba(options.apiKey, options),
|
|
110
|
+
},
|
|
111
|
+
],
|
|
112
|
+
exports: [POSTSHIBA],
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
return PostShibaModule = _classThis;
|
|
117
|
+
})();
|
|
118
|
+
export { PostShibaModule };
|
package/package.json
CHANGED
|
@@ -1,6 +1,61 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@postshiba/node",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "PostShiba API client",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "PostShiba",
|
|
7
|
+
"homepage": "https://github.com/postshiba/postshiba-node",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/postshiba/postshiba-node.git"
|
|
11
|
+
},
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/postshiba/postshiba-node/issues"
|
|
14
|
+
},
|
|
15
|
+
"type": "module",
|
|
16
|
+
"main": "./dist/index.js",
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"import": "./dist/index.js",
|
|
22
|
+
"default": "./dist/index.js"
|
|
23
|
+
},
|
|
24
|
+
"./nest": {
|
|
25
|
+
"types": "./dist/nest.d.ts",
|
|
26
|
+
"import": "./dist/nest.js",
|
|
27
|
+
"default": "./dist/nest.js"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"dist",
|
|
32
|
+
"LICENSE",
|
|
33
|
+
"README.md",
|
|
34
|
+
"CHANGELOG.md"
|
|
35
|
+
],
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"access": "public"
|
|
38
|
+
},
|
|
39
|
+
"engines": {
|
|
40
|
+
"node": ">=18"
|
|
41
|
+
},
|
|
42
|
+
"scripts": {
|
|
43
|
+
"build": "rm -rf dist && tsc -p tsconfig.build.json",
|
|
44
|
+
"prepublishOnly": "npm run build && npm test",
|
|
45
|
+
"test": "vitest run"
|
|
46
|
+
},
|
|
47
|
+
"peerDependencies": {
|
|
48
|
+
"@nestjs/common": "^10.0.0 || ^11.0.0"
|
|
49
|
+
},
|
|
50
|
+
"peerDependenciesMeta": {
|
|
51
|
+
"@nestjs/common": {
|
|
52
|
+
"optional": true
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@nestjs/common": "^11.1.6",
|
|
57
|
+
"@types/node": "^24.5.2",
|
|
58
|
+
"typescript": "^5.9.2",
|
|
59
|
+
"vitest": "^3.2.4"
|
|
60
|
+
}
|
|
61
|
+
}
|