@particle-academy/discord-js 0.1.1 → 0.1.3
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 +24 -0
- package/dist/flow.cjs +2 -1
- package/dist/flow.cjs.map +1 -1
- package/dist/flow.js +2 -1
- package/dist/flow.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,30 @@
|
|
|
3
3
|
All notable changes to `@particle-academy/discord-ui`,
|
|
4
4
|
`@particle-academy/discord-js`, `particle-academy/discord-php` and `fancy-discord`.
|
|
5
5
|
|
|
6
|
+
## [0.1.3] — 2026-09-12
|
|
7
|
+
|
|
8
|
+
### Fixed
|
|
9
|
+
|
|
10
|
+
- **An idempotency key longer than Discord's 25-character limit is now fitted to it instead of refused.** `Idempotency::keyFor` in the php executor and `idempotencyKeyFor` in the js one receive `maxLength: 25`, so an engine-derived `<runKey>:<nodeId>` that exceeds the limit is shortened by the core to a stable digest — the same key on every retry — rather than rejected by this package's own validation with `idempotencyKey must be at most 25 characters`. Before this, a durable run with a normal-length run identity died at `message_create` and nothing a host could do short of choosing a shorter identity would fix it. Found by the connector lab; the core's half shipped as fancy-connector-core 0.4.0.
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- **Requires `fancy-connector-core` ≥ 0.4.0** — `particle-academy/fancy-connector-core` for php, `@particle-academy/fancy-connector-core` for js. The flow executors now pass a provider's declared `idempotencyMaxLength` through to the core's key derivation, and a named argument an older core does not accept is a fatal rather than a no-op, so the floor moves with it. For this connector that is the fix above.
|
|
15
|
+
|
|
16
|
+
## [0.1.2] — 2026-09-11
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
|
|
20
|
+
- **`fancy-flow-php` executors for every node.** `src/Flow/` carries one `#[FlowNode]` class per action and trigger, and `DiscordFlow::EXECUTORS` lists them.
|
|
21
|
+
|
|
22
|
+
A Laravel host running fancy-flow-php could show this connector's nodes in its editor and could not run them: `particle-academy/discord-php` shipped the request builders and no executor. Each one is the PHP twin of the executor in `@particle-academy/discord-js` — the same kind, the same request, the same value on `out` — and an unsafe-to-replay action derives its idempotency key from the run and the node, so a retried durable run sends the key it sent the first time.
|
|
23
|
+
|
|
24
|
+
Register them by adding `vendor/particle-academy/discord-php/packages/php/src/Flow` to `config('fancy-flow.discover')`. `particle-academy/fancy-flow-php` is SUGGESTED, not required, and conflicts outside `>=0.51.0 <2.0`, the range the executors were tested under. Nothing outside `Flow\` needs it.
|
|
25
|
+
|
|
26
|
+
### Fixed
|
|
27
|
+
|
|
28
|
+
- **Fake mode through `ConnectorClient` threw.** `Discord::descriptor()` handed the connector core its faker as `DiscordFaker::respond(...)`, which takes `($operation, $request)`; the core calls a faker `($operation, $config, $fake, $input)`. So `$config` arrived as `$request` and every fake call died on "Call to a member function … on null". The descriptor now translates between the two. Calling `DiscordFaker::respond()` directly — what this package's own tests do, which is why they never saw it — is unchanged.
|
|
29
|
+
|
|
6
30
|
## [0.1.1] — 2026-09-06
|
|
7
31
|
|
|
8
32
|
### Changed
|
package/dist/flow.cjs
CHANGED
|
@@ -115,7 +115,8 @@ async function discordMessageCreate(options) {
|
|
|
115
115
|
var discordMessageExecutor = async (ctx) => {
|
|
116
116
|
const config = ctx.node.data?.config ?? {};
|
|
117
117
|
const idempotencyKey = fancyConnectorCore.idempotencyKeyFor(ctx, ctx.node.id, {
|
|
118
|
-
context: { service: "discord", operation: "message_create" }
|
|
118
|
+
context: { service: "discord", operation: "message_create" },
|
|
119
|
+
maxLength: 25
|
|
119
120
|
});
|
|
120
121
|
if (idempotencyKey === null) {
|
|
121
122
|
ctx.emit({
|
package/dist/flow.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/faker.ts","../src/service.ts","../src/actions/message-create.ts","../src/flow.ts"],"names":["callConnector","idempotencyKeyFor","NO_IDEMPOTENCY_KEY_WARNING","discordMessageKind"],"mappings":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-edit here is destroyed by the next protocol sync, which is worse than\n * being rejected, because it works until it silently does not. Fix\n * provider/fixtures/ (or weaver's template/) and regenerate:\n *\n * npm run provider -- discord\n */\n\n/**\n * The Discord faker.\n *\n * Shapes, not behaviour: the goal is that a downstream node sees the field\n * NAMES Discord actually publishes, so an author can wire {{ $json.data.id }}\n * against a fake and have it keep working against the real thing.\n *\n * Deterministic — same inputs, same output. A faker returning a fresh uuid\n * every call cannot be asserted on, so its fixtures degrade to \"it did not\n * throw\", which is the assertion that catches nothing.\n */\n\nimport type { ConnectorFaker, FakeRequest } from \"@particle-academy/fancy-connector-core\";\n\nfunction fakeMessageCreate({ config, fake }: FakeRequest): unknown {\n return {\n \"id\": \"1409987654321098765\",\n \"channel_id\": \"1409123456789012345\",\n \"author\": {\n \"id\": \"1409000000000000001\",\n \"username\": \"Release Bot\",\n \"avatar\": null,\n \"discriminator\": \"0000\",\n \"public_flags\": 0,\n \"flags\": 0,\n \"bot\": true,\n \"banner\": null,\n \"accent_color\": null,\n \"global_name\": null,\n \"avatar_decoration_data\": null,\n \"collectibles\": null,\n \"primary_guild\": null,\n },\n \"content\": \"Deployment finished successfully.\",\n \"timestamp\": \"2026-08-30T18:42:15.123000+00:00\",\n \"edited_timestamp\": null,\n \"tts\": false,\n \"mention_everyone\": false,\n \"mentions\": [],\n \"mention_roles\": [],\n \"attachments\": [],\n \"embeds\": [],\n \"pinned\": false,\n \"type\": 0,\n \"flags\": 0,\n \"components\": [],\n \"nonce\": \"run42-step7\",\n };\n}\n\nexport const discordFaker: ConnectorFaker = (operation, request) => {\n switch (operation) {\n case \"message_create\":\n return fakeMessageCreate(request);\n\n default:\n // A faker asked for an operation it has no shape for must SAY so. Making\n // something up would produce a green run whose output silently has none\n // of the fields the author is about to reference.\n throw new Error(\n `discord: no fake response is defined for \"${operation}\". ` +\n \"Add a fixture under provider/fixtures/ and regenerate — a connector without a faker \" +\n \"cannot be developed against, tested, or demonstrated.\",\n );\n }\n};\n","/**\n * GENERATED FILE — do not edit.\n *\n * Emitted from provider/manifest.json by weaver's generator.\n * A hand-edit here is destroyed by the next protocol sync, which is worse than\n * being rejected, because it works until it silently does not. Fix\n * provider/manifest.json (or weaver's template/) and regenerate:\n *\n * npm run provider -- discord\n */\n\n/**\n * Discord, as one service descriptor shared by every Discord operation.\n *\n * @particle-academy/fancy-connector-core carries what is true of ALL\n * connectors. This carries what is true of Discord: its base URL, its auth\n * scheme, its idempotency header, and its faker.\n *\n * ## The sandbox trap, written down where it is used\n *\n * Create a development-only Discord application, install its bot into a\n * dedicated test server, and use a test channel id. Messages are real and can\n * notify members of that server; production credentials sent in sandbox mode\n * are not technically rejected.\n */\n\nimport type { ConnectorMode, PreparedRequest, ServiceDescriptor } from \"@particle-academy/fancy-connector-core\";\n\nimport { discordFaker } from \"./faker.js\";\n\n/**\n * The connector API version this package was GENERATED against.\n *\n * A literal, never imported. An imported constant lets an upgrade rewrite the\n * very claim it exists to detect, after which the copy agrees with itself\n * forever.\n */\nexport const CONNECTOR_API_VERSION = 1;\n\nexport const DISCORD_BASE_URLS = {\n \"live\": \"https://discord.com/api/v10\",\n \"sandbox\": \"https://discord.com/api/v10\"\n} as const;\n\n/** Credential keys a remote call cannot proceed without. */\nexport const DISCORD_REQUIRES = [\n \"botToken\"\n] as const;\n\n/**\n * Apply Discord's auth scheme to an outgoing request.\n *\n * A bot token authenticates as the application's dedicated bot user, not as a\n * human through OAuth2. Discord requires the literal `Bot ` scheme; using\n * Bearer would describe a user OAuth token and a different permission model.\n *\n * The mode is passed in because for some providers auth and estate are the\n * same decision expressed in the URL; here it is unused, and saying so is\n * cheaper than wondering later whether it was forgotten.\n */\nexport function discordAuthorize(\n credentials: Record<string, string | undefined>,\n request: PreparedRequest,\n _mode: ConnectorMode,\n): void {\n request.headers[\"Authorization\"] = `Bot ${credentials.botToken ?? \"\"}`;\n}\n\n/** The Discord service, for the TypeScript runtime. */\nexport const DISCORD: ServiceDescriptor = {\n service: \"discord\",\n title: \"Discord\",\n sandbox: \"separate-account\",\n baseUrls: { ...DISCORD_BASE_URLS },\n requires: [...DISCORD_REQUIRES],\n authorize: discordAuthorize,\n faker: discordFaker,\n};\n","/**\n * GENERATED FILE — do not edit.\n *\n * Emitted from provider/actions/message-create.json by weaver's generator.\n * A hand-edit here is destroyed by the next protocol sync, which is worse than\n * being rejected, because it works until it silently does not. Fix\n * provider/actions/message-create.json (or weaver's template/) and regenerate:\n *\n * npm run provider -- discord\n */\n\n/**\n * Send a text message to a Discord channel.\n *\n * POST /channels/{channelId}/messages —\n * https://docs.discord.com/developers/resources/message#create-message\n *\n * Notice what is NOT here: no key, no base URL, no mode check, no retry loop,\n * no fake/real branch. This describes the request; callConnector resolves the\n * connection, picks the estate, and either calls Discord or calls the faker.\n */\n\nimport {\n callConnector,\n type ConnectorResult,\n type RequestedMode,\n type Transport,\n} from \"@particle-academy/fancy-connector-core\";\nimport { DISCORD } from \"../service.js\";\n\nexport const MESSAGE_CREATE_OPERATION = \"message_create\";\n\nexport type MessageCreateOptions = {\n /** The node's resolved config. Keys: channelId, content. */\n config: Record<string, unknown>;\n credentials?: Record<string, string | undefined>;\n mode?: RequestedMode;\n connectionId?: string | null;\n input?: unknown;\n /** Derived from the run and the step, never fresh. See the note above. */\n idempotencyKey?: string;\n attempts?: number;\n /** Override the transport. The only way to exercise this without a network. */\n transport?: Transport;\n};\n\nexport async function discordMessageCreate(options: MessageCreateOptions): Promise<ConnectorResult> {\n const config = options.config ?? {};\n\n if (config.channelId === undefined || config.channelId === null || config.channelId === \"\") {\n throw new Error(`message_create: \"channelId\" is required (Channel ID).`);\n }\n\n if (config.content === undefined || config.content === null || config.content === \"\") {\n throw new Error(`message_create: \"content\" is required (Message).`);\n }\n\n if (options.idempotencyKey === undefined || options.idempotencyKey === \"\") {\n throw new Error(\n \"message_create: an idempotencyKey is required — derive it from the RUN and the STEP, \" +\n \"never fresh, or a retried run takes a second payment.\",\n );\n }\n\n if (options.idempotencyKey.length > 25) {\n throw new Error(\"message_create: idempotencyKey must be at most 25 characters.\");\n }\n\n return callConnector(DISCORD, {\n operation: MESSAGE_CREATE_OPERATION,\n config,\n input: options.input,\n ...(options.credentials === undefined ? {} : { credentials: options.credentials }),\n ...(options.mode === undefined ? {} : { mode: options.mode }),\n ...(options.connectionId === undefined ? {} : { connectionId: options.connectionId }),\n ...(options.attempts === undefined ? {} : { attempts: options.attempts }),\n ...(options.transport === undefined ? {} : { transport: options.transport }),\n request: {\n method: \"POST\",\n path: `/channels/${encodeURIComponent(String(config.channelId))}/messages`,\n json: {\n \"content\": String(config.content),\n \"nonce\": options.idempotencyKey,\n \"enforce_nonce\": true,\n \"allowed_mentions\": {\"parse\":[]},\n },\n },\n });\n}\n","/**\n * GENERATED FILE — do not edit.\n *\n * Emitted from provider/actions/ + triggers/ by weaver's generator.\n * A hand-edit here is destroyed by the next protocol sync, which is worse than\n * being rejected, because it works until it silently does not. Fix\n * provider/actions/ + triggers/ (or weaver's template/) and regenerate:\n *\n * npm run provider -- discord\n */\n\n/**\n * Discord's node kinds with their TypeScript executors attached — for hosts\n * that EXECUTE on TS.\n *\n * The authoring surface in @particle-academy/discord-ui carries no executor:\n * the editor is React on every host, so a PHP or Python project installs the\n * ui package and never this one.\n */\n\nimport type { NodeExecutor, NodeKindDefinition } from \"@particle-academy/fancy-flow/engine\";\nimport {\n idempotencyKeyFor,\n NO_IDEMPOTENCY_KEY_WARNING,\n resolveConnection,\n triggerEvent,\n type RequestedMode,\n} from \"@particle-academy/fancy-connector-core\";\nimport { DISCORD } from \"./service.js\";\n\nimport {\n discordMessageKind,\n} from \"@particle-academy/discord-ui\";\n\nimport { discordMessageCreate } from \"./actions/message-create.js\";\n\nexport const discordMessageExecutor: NodeExecutor = async (ctx) => {\n const config = ((ctx.node.data as { config?: Record<string, unknown> })?.config ?? {});\n\n // Derived from the RUN and the NODE, never fresh. A retried durable run\n // must send the same key or Discord creates a second one — the exact\n // failure \"idempotent\" exists to prevent.\n const idempotencyKey = idempotencyKeyFor(ctx, ctx.node.id, {\n context: { service: \"discord\", operation: \"message_create\" },\n });\n if (idempotencyKey === null) {\n ctx.emit({\n type: \"log\",\n level: \"warn\",\n nodeId: ctx.node.id,\n message: `message_create: ${NO_IDEMPOTENCY_KEY_WARNING}`,\n });\n }\n\n const result = await discordMessageCreate({\n config,\n input: ctx.inputs?.in,\n ...(idempotencyKey === null ? {} : { idempotencyKey }),\n });\n\n ctx.emit({\n type: \"log\",\n level: \"info\",\n nodeId: ctx.node.id,\n message: `discord message_create ${(result.data as { id?: string })?.id} (${result.mode})`,\n });\n\n return { __port: \"out\", value: result };\n};\n\n/** The kinds a TypeScript host registers. */\nexport const DISCORD_RUNNABLE_KINDS: NodeKindDefinition[] = [\n { ...discordMessageKind, executor: discordMessageExecutor },\n];\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/faker.ts","../src/service.ts","../src/actions/message-create.ts","../src/flow.ts"],"names":["callConnector","idempotencyKeyFor","NO_IDEMPOTENCY_KEY_WARNING","discordMessageKind"],"mappings":";;;;;;;;AAyBA,SAAS,iBAAA,CAAkB,EAAE,MAAA,EAAQ,IAAA,EAAK,EAAyB;AACjE,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,qBAAA;AAAA,IACN,YAAA,EAAc,qBAAA;AAAA,IACd,QAAA,EAAU;AAAA,MACR,IAAA,EAAM,qBAAA;AAAA,MACN,UAAA,EAAY,aAAA;AAAA,MACZ,QAAA,EAAU,IAAA;AAAA,MACV,eAAA,EAAiB,MAAA;AAAA,MACjB,cAAA,EAAgB,CAAA;AAAA,MAChB,OAAA,EAAS,CAAA;AAAA,MACT,KAAA,EAAO,IAAA;AAAA,MACP,QAAA,EAAU,IAAA;AAAA,MACV,cAAA,EAAgB,IAAA;AAAA,MAChB,aAAA,EAAe,IAAA;AAAA,MACf,wBAAA,EAA0B,IAAA;AAAA,MAC1B,cAAA,EAAgB,IAAA;AAAA,MAChB,eAAA,EAAiB;AAAA,KACnB;AAAA,IACA,SAAA,EAAW,mCAAA;A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AAAA,IACA,KAAA,EAAO,IAAI,MAAA,EAAQ,EAAA;AAAA,IACnB,GAAI,cAAA,KAAmB,IAAA,GAAO,EAAC,GAAI,EAAE,cAAA;AAAe,GACrD,CAAA;AAED,EAAA,GAAA,CAAI,IAAA,CAAK;AAAA,IACP,IAAA,EAAM,KAAA;AAAA,IACN,KAAA,EAAO,MAAA;AAAA,IACP,MAAA,EAAQ,IAAI,IAAA,CAAK,EAAA;AAAA,IACjB,SAAS,CAAA,uBAAA,EAA2B,MAAA,CAAO,MAA0B,EAAE,CAAA,EAAA,EAAK,OAAO,IAAI,CAAA,CAAA;AAAA,GACxF,CAAA;AAED,EAAA,OAAO,EAAE,MAAA,EAAQ,KAAA,EAAO,KAAA,EAAO,MAAA,EAAO;AACxC;AAGO,IAAM,sBAAA,GAA+C;AAAA,EAC1D,EAAE,GAAGC,4BAAA,EAAoB,QAAA,EAAU,sBAAA;AACrC","file":"flow.cjs","sourcesContent":["/**\n * GENERATED FILE — do not edit.\n *\n * Emitted from provider/fixtures/ by weaver's generator.\n * A hand-edit here is destroyed by the next protocol sync, which is worse than\n * being rejected, because it works until it silently does not. Fix\n * provider/fixtures/ (or weaver's template/) and regenerate:\n *\n * npm run provider -- discord\n */\n\n/**\n * The Discord faker.\n *\n * Shapes, not behaviour: the goal is that a downstream node sees the field\n * NAMES Discord actually publishes, so an author can wire {{ $json.data.id }}\n * against a fake and have it keep working against the real thing.\n *\n * Deterministic — same inputs, same output. A faker returning a fresh uuid\n * every call cannot be asserted on, so its fixtures degrade to \"it did not\n * throw\", which is the assertion that catches nothing.\n */\n\nimport type { ConnectorFaker, FakeRequest } from \"@particle-academy/fancy-connector-core\";\n\nfunction fakeMessageCreate({ config, fake }: FakeRequest): unknown {\n return {\n \"id\": \"1409987654321098765\",\n \"channel_id\": \"1409123456789012345\",\n \"author\": {\n \"id\": \"1409000000000000001\",\n \"username\": \"Release Bot\",\n \"avatar\": null,\n \"discriminator\": \"0000\",\n \"public_flags\": 0,\n \"flags\": 0,\n \"bot\": true,\n \"banner\": null,\n \"accent_color\": null,\n \"global_name\": null,\n \"avatar_decoration_data\": null,\n \"collectibles\": null,\n \"primary_guild\": null,\n },\n \"content\": \"Deployment finished successfully.\",\n \"timestamp\": \"2026-08-30T18:42:15.123000+00:00\",\n \"edited_timestamp\": null,\n \"tts\": false,\n \"mention_everyone\": false,\n \"mentions\": [],\n \"mention_roles\": [],\n \"attachments\": [],\n \"embeds\": [],\n \"pinned\": false,\n \"type\": 0,\n \"flags\": 0,\n \"components\": [],\n \"nonce\": \"run42-step7\",\n };\n}\n\nexport const discordFaker: ConnectorFaker = (operation, request) => {\n switch (operation) {\n case \"message_create\":\n return fakeMessageCreate(request);\n\n default:\n // A faker asked for an operation it has no shape for must SAY so. Making\n // something up would produce a green run whose output silently has none\n // of the fields the author is about to reference.\n throw new Error(\n `discord: no fake response is defined for \"${operation}\". ` +\n \"Add a fixture under provider/fixtures/ and regenerate — a connector without a faker \" +\n \"cannot be developed against, tested, or demonstrated.\",\n );\n }\n};\n","/**\n * GENERATED FILE — do not edit.\n *\n * Emitted from provider/manifest.json by weaver's generator.\n * A hand-edit here is destroyed by the next protocol sync, which is worse than\n * being rejected, because it works until it silently does not. Fix\n * provider/manifest.json (or weaver's template/) and regenerate:\n *\n * npm run provider -- discord\n */\n\n/**\n * Discord, as one service descriptor shared by every Discord operation.\n *\n * @particle-academy/fancy-connector-core carries what is true of ALL\n * connectors. This carries what is true of Discord: its base URL, its auth\n * scheme, its idempotency header, and its faker.\n *\n * ## The sandbox trap, written down where it is used\n *\n * Create a development-only Discord application, install its bot into a\n * dedicated test server, and use a test channel id. Messages are real and can\n * notify members of that server; production credentials sent in sandbox mode\n * are not technically rejected.\n */\n\nimport type { ConnectorMode, PreparedRequest, ServiceDescriptor } from \"@particle-academy/fancy-connector-core\";\n\nimport { discordFaker } from \"./faker.js\";\n\n/**\n * The connector API version this package was GENERATED against.\n *\n * A literal, never imported. An imported constant lets an upgrade rewrite the\n * very claim it exists to detect, after which the copy agrees with itself\n * forever.\n */\nexport const CONNECTOR_API_VERSION = 1;\n\nexport const DISCORD_BASE_URLS = {\n \"live\": \"https://discord.com/api/v10\",\n \"sandbox\": \"https://discord.com/api/v10\"\n} as const;\n\n/** Credential keys a remote call cannot proceed without. */\nexport const DISCORD_REQUIRES = [\n \"botToken\"\n] as const;\n\n/**\n * Apply Discord's auth scheme to an outgoing request.\n *\n * A bot token authenticates as the application's dedicated bot user, not as a\n * human through OAuth2. Discord requires the literal `Bot ` scheme; using\n * Bearer would describe a user OAuth token and a different permission model.\n *\n * The mode is passed in because for some providers auth and estate are the\n * same decision expressed in the URL; here it is unused, and saying so is\n * cheaper than wondering later whether it was forgotten.\n */\nexport function discordAuthorize(\n credentials: Record<string, string | undefined>,\n request: PreparedRequest,\n _mode: ConnectorMode,\n): void {\n request.headers[\"Authorization\"] = `Bot ${credentials.botToken ?? \"\"}`;\n}\n\n/** The Discord service, for the TypeScript runtime. */\nexport const DISCORD: ServiceDescriptor = {\n service: \"discord\",\n title: \"Discord\",\n sandbox: \"separate-account\",\n baseUrls: { ...DISCORD_BASE_URLS },\n requires: [...DISCORD_REQUIRES],\n authorize: discordAuthorize,\n faker: discordFaker,\n};\n","/**\n * GENERATED FILE — do not edit.\n *\n * Emitted from provider/actions/message-create.json by weaver's generator.\n * A hand-edit here is destroyed by the next protocol sync, which is worse than\n * being rejected, because it works until it silently does not. Fix\n * provider/actions/message-create.json (or weaver's template/) and regenerate:\n *\n * npm run provider -- discord\n */\n\n/**\n * Send a text message to a Discord channel.\n *\n * POST /channels/{channelId}/messages —\n * https://docs.discord.com/developers/resources/message#create-message\n *\n * Notice what is NOT here: no key, no base URL, no mode check, no retry loop,\n * no fake/real branch. This describes the request; callConnector resolves the\n * connection, picks the estate, and either calls Discord or calls the faker.\n */\n\nimport {\n callConnector,\n type ConnectorResult,\n type RequestedMode,\n type Transport,\n} from \"@particle-academy/fancy-connector-core\";\nimport { DISCORD } from \"../service.js\";\n\nexport const MESSAGE_CREATE_OPERATION = \"message_create\";\n\nexport type MessageCreateOptions = {\n /** The node's resolved config. Keys: channelId, content. */\n config: Record<string, unknown>;\n credentials?: Record<string, string | undefined>;\n mode?: RequestedMode;\n connectionId?: string | null;\n input?: unknown;\n /** Derived from the run and the step, never fresh. See the note above. */\n idempotencyKey?: string;\n attempts?: number;\n /** Override the transport. The only way to exercise this without a network. */\n transport?: Transport;\n};\n\nexport async function discordMessageCreate(options: MessageCreateOptions): Promise<ConnectorResult> {\n const config = options.config ?? {};\n\n if (config.channelId === undefined || config.channelId === null || config.channelId === \"\") {\n throw new Error(`message_create: \"channelId\" is required (Channel ID).`);\n }\n\n if (config.content === undefined || config.content === null || config.content === \"\") {\n throw new Error(`message_create: \"content\" is required (Message).`);\n }\n\n if (options.idempotencyKey === undefined || options.idempotencyKey === \"\") {\n throw new Error(\n \"message_create: an idempotencyKey is required — derive it from the RUN and the STEP, \" +\n \"never fresh, or a retried run takes a second payment.\",\n );\n }\n\n if (options.idempotencyKey.length > 25) {\n throw new Error(\"message_create: idempotencyKey must be at most 25 characters.\");\n }\n\n return callConnector(DISCORD, {\n operation: MESSAGE_CREATE_OPERATION,\n config,\n input: options.input,\n ...(options.credentials === undefined ? {} : { credentials: options.credentials }),\n ...(options.mode === undefined ? {} : { mode: options.mode }),\n ...(options.connectionId === undefined ? {} : { connectionId: options.connectionId }),\n ...(options.attempts === undefined ? {} : { attempts: options.attempts }),\n ...(options.transport === undefined ? {} : { transport: options.transport }),\n request: {\n method: \"POST\",\n path: `/channels/${encodeURIComponent(String(config.channelId))}/messages`,\n json: {\n \"content\": String(config.content),\n \"nonce\": options.idempotencyKey,\n \"enforce_nonce\": true,\n \"allowed_mentions\": {\"parse\":[]},\n },\n },\n });\n}\n","/**\n * GENERATED FILE — do not edit.\n *\n * Emitted from provider/actions/ + triggers/ by weaver's generator.\n * A hand-edit here is destroyed by the next protocol sync, which is worse than\n * being rejected, because it works until it silently does not. Fix\n * provider/actions/ + triggers/ (or weaver's template/) and regenerate:\n *\n * npm run provider -- discord\n */\n\n/**\n * Discord's node kinds with their TypeScript executors attached — for hosts\n * that EXECUTE on TS.\n *\n * The authoring surface in @particle-academy/discord-ui carries no executor:\n * the editor is React on every host, so a PHP or Python project installs the\n * ui package and never this one.\n */\n\nimport type { NodeExecutor, NodeKindDefinition } from \"@particle-academy/fancy-flow/engine\";\nimport {\n idempotencyKeyFor,\n NO_IDEMPOTENCY_KEY_WARNING,\n resolveConnection,\n triggerEvent,\n type RequestedMode,\n} from \"@particle-academy/fancy-connector-core\";\nimport { DISCORD } from \"./service.js\";\n\nimport {\n discordMessageKind,\n} from \"@particle-academy/discord-ui\";\n\nimport { discordMessageCreate } from \"./actions/message-create.js\";\n\nexport const discordMessageExecutor: NodeExecutor = async (ctx) => {\n const config = ((ctx.node.data as { config?: Record<string, unknown> })?.config ?? {});\n\n // Derived from the RUN and the NODE, never fresh. A retried durable run\n // must send the same key or Discord creates a second one — the exact\n // failure \"idempotent\" exists to prevent.\n const idempotencyKey = idempotencyKeyFor(ctx, ctx.node.id, {\n context: { service: \"discord\", operation: \"message_create\" },\n maxLength: 25,\n });\n if (idempotencyKey === null) {\n ctx.emit({\n type: \"log\",\n level: \"warn\",\n nodeId: ctx.node.id,\n message: `message_create: ${NO_IDEMPOTENCY_KEY_WARNING}`,\n });\n }\n\n const result = await discordMessageCreate({\n config,\n input: ctx.inputs?.in,\n ...(idempotencyKey === null ? {} : { idempotencyKey }),\n });\n\n ctx.emit({\n type: \"log\",\n level: \"info\",\n nodeId: ctx.node.id,\n message: `discord message_create ${(result.data as { id?: string })?.id} (${result.mode})`,\n });\n\n return { __port: \"out\", value: result };\n};\n\n/** The kinds a TypeScript host registers. */\nexport const DISCORD_RUNNABLE_KINDS: NodeKindDefinition[] = [\n { ...discordMessageKind, executor: discordMessageExecutor },\n];\n"]}
|
package/dist/flow.js
CHANGED
|
@@ -5,7 +5,8 @@ import { discordMessageKind } from '@particle-academy/discord-ui';
|
|
|
5
5
|
var discordMessageExecutor = async (ctx) => {
|
|
6
6
|
const config = ctx.node.data?.config ?? {};
|
|
7
7
|
const idempotencyKey = idempotencyKeyFor(ctx, ctx.node.id, {
|
|
8
|
-
context: { service: "discord", operation: "message_create" }
|
|
8
|
+
context: { service: "discord", operation: "message_create" },
|
|
9
|
+
maxLength: 25
|
|
9
10
|
});
|
|
10
11
|
if (idempotencyKey === null) {
|
|
11
12
|
ctx.emit({
|
package/dist/flow.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/flow.ts"],"names":[],"mappings":";;;;AAoCO,IAAM,sBAAA,GAAuC,OAAO,GAAA,KAAQ;AACjE,EAAA,MAAM,MAAA,GAAW,GAAA,CAAI,IAAA,CAAK,IAAA,EAA+C,UAAU,EAAC;AAKpF,EAAA,MAAM,cAAA,GAAiB,iBAAA,CAAkB,GAAA,EAAK,GAAA,CAAI,KAAK,EAAA,EAAI;AAAA,IACzD,OAAA,EAAS,EAAE,OAAA,EAAS,SAAA,EAAW,WAAW,gBAAA;
|
|
1
|
+
{"version":3,"sources":["../src/flow.ts"],"names":[],"mappings":";;;;AAoCO,IAAM,sBAAA,GAAuC,OAAO,GAAA,KAAQ;AACjE,EAAA,MAAM,MAAA,GAAW,GAAA,CAAI,IAAA,CAAK,IAAA,EAA+C,UAAU,EAAC;AAKpF,EAAA,MAAM,cAAA,GAAiB,iBAAA,CAAkB,GAAA,EAAK,GAAA,CAAI,KAAK,EAAA,EAAI;AAAA,IACzD,OAAA,EAAS,EAAE,OAAA,EAAS,SAAA,EAAW,WAAW,gBAAA,EAAiB;AAAA,IAC3D,SAAA,EAAW;AAAA,GACZ,CAAA;AACD,EAAA,IAAI,mBAAmB,IAAA,EAAM;AAC3B,IAAA,GAAA,CAAI,IAAA,CAAK;AAAA,MACP,IAAA,EAAM,KAAA;AAAA,MACN,KAAA,EAAO,MAAA;AAAA,MACP,MAAA,EAAQ,IAAI,IAAA,CAAK,EAAA;AAAA,MACjB,OAAA,EAAS,mBAAmB,0BAA0B,CAAA;AAAA,KACvD,CAAA;AAAA,EACH;AAEA,EAAA,MAAM,MAAA,GAAS,MAAM,oBAAA,CAAqB;AAAA,IACxC,MAAA;AAAA,IACA,KAAA,EAAO,IAAI,MAAA,EAAQ,EAAA;AAAA,IACnB,GAAI,cAAA,KAAmB,IAAA,GAAO,EAAC,GAAI,EAAE,cAAA;AAAe,GACrD,CAAA;AAED,EAAA,GAAA,CAAI,IAAA,CAAK;AAAA,IACP,IAAA,EAAM,KAAA;AAAA,IACN,KAAA,EAAO,MAAA;AAAA,IACP,MAAA,EAAQ,IAAI,IAAA,CAAK,EAAA;AAAA,IACjB,SAAS,CAAA,uBAAA,EAA2B,MAAA,CAAO,MAA0B,EAAE,CAAA,EAAA,EAAK,OAAO,IAAI,CAAA,CAAA;AAAA,GACxF,CAAA;AAED,EAAA,OAAO,EAAE,MAAA,EAAQ,KAAA,EAAO,KAAA,EAAO,MAAA,EAAO;AACxC;AAGO,IAAM,sBAAA,GAA+C;AAAA,EAC1D,EAAE,GAAG,kBAAA,EAAoB,QAAA,EAAU,sBAAA;AACrC","file":"flow.js","sourcesContent":["/**\n * GENERATED FILE — do not edit.\n *\n * Emitted from provider/actions/ + triggers/ by weaver's generator.\n * A hand-edit here is destroyed by the next protocol sync, which is worse than\n * being rejected, because it works until it silently does not. Fix\n * provider/actions/ + triggers/ (or weaver's template/) and regenerate:\n *\n * npm run provider -- discord\n */\n\n/**\n * Discord's node kinds with their TypeScript executors attached — for hosts\n * that EXECUTE on TS.\n *\n * The authoring surface in @particle-academy/discord-ui carries no executor:\n * the editor is React on every host, so a PHP or Python project installs the\n * ui package and never this one.\n */\n\nimport type { NodeExecutor, NodeKindDefinition } from \"@particle-academy/fancy-flow/engine\";\nimport {\n idempotencyKeyFor,\n NO_IDEMPOTENCY_KEY_WARNING,\n resolveConnection,\n triggerEvent,\n type RequestedMode,\n} from \"@particle-academy/fancy-connector-core\";\nimport { DISCORD } from \"./service.js\";\n\nimport {\n discordMessageKind,\n} from \"@particle-academy/discord-ui\";\n\nimport { discordMessageCreate } from \"./actions/message-create.js\";\n\nexport const discordMessageExecutor: NodeExecutor = async (ctx) => {\n const config = ((ctx.node.data as { config?: Record<string, unknown> })?.config ?? {});\n\n // Derived from the RUN and the NODE, never fresh. A retried durable run\n // must send the same key or Discord creates a second one — the exact\n // failure \"idempotent\" exists to prevent.\n const idempotencyKey = idempotencyKeyFor(ctx, ctx.node.id, {\n context: { service: \"discord\", operation: \"message_create\" },\n maxLength: 25,\n });\n if (idempotencyKey === null) {\n ctx.emit({\n type: \"log\",\n level: \"warn\",\n nodeId: ctx.node.id,\n message: `message_create: ${NO_IDEMPOTENCY_KEY_WARNING}`,\n });\n }\n\n const result = await discordMessageCreate({\n config,\n input: ctx.inputs?.in,\n ...(idempotencyKey === null ? {} : { idempotencyKey }),\n });\n\n ctx.emit({\n type: \"log\",\n level: \"info\",\n nodeId: ctx.node.id,\n message: `discord message_create ${(result.data as { id?: string })?.id} (${result.mode})`,\n });\n\n return { __port: \"out\", value: result };\n};\n\n/** The kinds a TypeScript host registers. */\nexport const DISCORD_RUNNABLE_KINDS: NodeKindDefinition[] = [\n { ...discordMessageKind, executor: discordMessageExecutor },\n];\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@particle-academy/discord-js",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Discord for Node — the service descriptor, its faker, its webhook verification, and one function per operation. Plain HTTP on @particle-academy/fancy-connector-core; no vendor SDK.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"prepublishOnly": "tsup"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@particle-academy/fancy-connector-core": ">=0.
|
|
52
|
+
"@particle-academy/fancy-connector-core": ">=0.4.0 <2.0"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
55
|
"@particle-academy/fancy-flow": ">=0.47.1 <2.0",
|