@betternotify/discord 0.0.3-alpha.0 → 1.0.0-beta.1

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 ADDED
@@ -0,0 +1,87 @@
1
+ # @betternotify/discord
2
+
3
+ Discord channel for [Better-Notify](https://github.com/better-notify/better-notify). Provides `discordChannel()`, a `mockDiscordTransport` for tests, and a `discordTransport` that posts to Discord webhooks.
4
+
5
+ <p>
6
+ <a href="https://better-notify.com">Website</a> ·
7
+ <a href="https://better-notify.com/docs">Docs</a> ·
8
+ <a href="https://github.com/better-notify/better-notify">GitHub</a> ·
9
+ <a href="https://x.com/better_notify">X</a>
10
+ </p>
11
+
12
+ ## Install
13
+
14
+ ```sh
15
+ npm install @betternotify/discord @betternotify/core
16
+ ```
17
+
18
+ ## Usage
19
+
20
+ ```ts
21
+ import { createNotify, createClient } from '@betternotify/core';
22
+ import { discordChannel, mockDiscordTransport } from '@betternotify/discord';
23
+ import { z } from 'zod';
24
+
25
+ const discord = discordChannel();
26
+ const rpc = createNotify({ channels: { discord } });
27
+
28
+ const catalog = rpc.catalog({
29
+ deployAlert: rpc
30
+ .discord()
31
+ .input(z.object({ service: z.string(), version: z.string() }))
32
+ .body(({ input }) => `**${input.service}** deployed v${input.version}`)
33
+ .embeds(({ input }) => [
34
+ {
35
+ title: 'Deployment',
36
+ fields: [
37
+ { name: 'Service', value: input.service, inline: true },
38
+ { name: 'Version', value: input.version, inline: true },
39
+ ],
40
+ },
41
+ ]),
42
+ });
43
+
44
+ const notify = createClient({
45
+ catalog,
46
+ channels: { discord },
47
+ transportsByChannel: { discord: mockDiscordTransport() },
48
+ });
49
+
50
+ await notify.deployAlert.send({
51
+ to: 'https://discord.com/api/webhooks/...',
52
+ input: { service: 'api', version: '2.1.0' },
53
+ });
54
+ ```
55
+
56
+ ## Builder slots
57
+
58
+ | Slot | Required | Type |
59
+ | -------- | -------- | ----------------------------------------------- |
60
+ | `body` | yes | `string \| ({input}) => string` |
61
+ | `embeds` | no | `DiscordEmbed[] \| ({input}) => DiscordEmbed[]` |
62
+
63
+ Plus `.input(schema)` and `.use(mw)`.
64
+
65
+ ## Send args
66
+
67
+ ```ts
68
+ notify.deployAlert.send({
69
+ to: string, // Discord webhook URL
70
+ input: TInput,
71
+ });
72
+ ```
73
+
74
+ ## Transports
75
+
76
+ ```ts
77
+ import { discordTransport, mockDiscordTransport } from '@betternotify/discord';
78
+ ```
79
+
80
+ - `mockDiscordTransport()` — records sent messages for tests.
81
+ - `discordTransport()` — posts to Discord webhook URLs via `fetch`.
82
+
83
+ Custom transport contract: `Transport<RenderedDiscord, DiscordTransportData>`.
84
+
85
+ ## License
86
+
87
+ MIT
package/dist/index.js CHANGED
@@ -1794,7 +1794,6 @@ const createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params)
1794
1794
  const neverProcessor = (_schema, _ctx, json, _params) => {
1795
1795
  json.not = {};
1796
1796
  };
1797
- const unknownProcessor = (_schema, _ctx, _json, _params) => {};
1798
1797
  const enumProcessor = (schema, _ctx, json, _params) => {
1799
1798
  const def = schema._zod.def;
1800
1799
  const values = getEnumValues(def.entries);
@@ -2064,7 +2063,7 @@ const ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
2064
2063
  const ZodUnknown = /* @__PURE__ */ $constructor("ZodUnknown", (inst, def) => {
2065
2064
  $ZodUnknown.init(inst, def);
2066
2065
  ZodType.init(inst, def);
2067
- inst._zod.processJSONSchema = (ctx, json, params) => unknownProcessor(inst, ctx, json, params);
2066
+ inst._zod.processJSONSchema = (ctx, json, params) => void 0;
2068
2067
  });
2069
2068
  function unknown() {
2070
2069
  return /* @__PURE__ */ _unknown(ZodUnknown);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@betternotify/discord",
3
- "version": "0.0.3-alpha.0",
3
+ "version": "1.0.0-beta.1",
4
4
  "description": "Discord channel plugin for betternotify.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -24,14 +24,14 @@
24
24
  "dependencies": {
25
25
  "@standard-schema/spec": "1.1.0",
26
26
  "zod": "4.3.6",
27
- "@betternotify/core": "0.0.5-alpha.0"
27
+ "@betternotify/core": "1.0.0-beta.1"
28
28
  },
29
29
  "devDependencies": {
30
- "rolldown": "1.0.0-rc.17",
30
+ "rolldown": "1.0.0",
31
31
  "typescript": "6.0.3",
32
32
  "vitest": "2.1.9",
33
- "@internal/tsconfig": "0.0.0",
34
- "@internal/rolldown-config": "0.0.0"
33
+ "@internal/rolldown-config": "0.0.0",
34
+ "@internal/tsconfig": "0.0.0"
35
35
  },
36
36
  "engines": {
37
37
  "node": ">=22"