Skip to content

Commit 4517af3

Browse files
dahliacodex
andcommitted
Upgrade BotKit to Fedify 2.0
Align BotKit with Fedify 2.0.3 and its modular package split. Move vocab and runtime imports to @fedify/vocab, @fedify/vocab-runtime, and @fedify/denokv. Update the public API to match Fedify 2.0 by replacing LanguageTag-based surfaces with Intl.Locale, using plain strings for software.version, and removing parseSemVer(), SemVer, LanguageTag, and parseLanguageTag() exports. Refresh examples, docs, and CHANGES.md to reflect the new package paths and API changes. Update lockfiles and manifests for the new dependency graph. Co-Authored-By: Codex <codex@openai.com>
1 parent 7081a0a commit 4517af3

43 files changed

Lines changed: 533 additions & 294 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGES.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,17 @@ To be released.
2020
automatically redirects to the appropriate follow page using the OStatus
2121
subscribe protocol.
2222

23-
- Upgraded Fedify to 1.10.0.
23+
- Upgraded Fedify to 2.0.3.
24+
25+
- BotKit now targets Fedify 2.0's modular package layout, using
26+
*@fedify/vocab*, *@fedify/vocab-runtime*, and *@fedify/denokv*
27+
where appropriate.
28+
- `Message.language` and `SessionPublishOptions.language` now use
29+
`Intl.Locale` instead of `LanguageTag`.
30+
- Bot software versions now use plain strings instead of `SemVer`
31+
objects.
32+
- Removed the `parseSemVer()`, `SemVer`, `LanguageTag`, and
33+
`parseLanguageTag()` public exports.
2434

2535
[#10]: https://github.com/fedify-dev/botkit/issues/10
2636
[#14]: https://github.com/fedify-dev/botkit/pull/14

deno.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
"workspace": ["packages/*", "examples/*"],
33
"unstable": ["kv", "temporal"],
44
"imports": {
5-
"@fedify/fedify": "jsr:@fedify/fedify@1.10.0",
5+
"@fedify/denokv": "jsr:@fedify/denokv@2.0.3",
6+
"@fedify/fedify": "jsr:@fedify/fedify@2.0.3",
7+
"@fedify/vocab": "jsr:@fedify/vocab@2.0.3",
8+
"@fedify/vocab-runtime": "jsr:@fedify/vocab-runtime@2.0.3",
69
"@logtape/logtape": "jsr:@logtape/logtape@^1.3.5",
710
"@std/fs": "jsr:@std/fs@^1.0.19",
811
"@std/path": "jsr:@std/path@^1.1.1",

deno.lock

Lines changed: 84 additions & 39 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/concepts/bot.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,18 +237,17 @@ It consists of the following properties:
237237
and hyphens.
238238

239239
`version` (required)
240-
: The version of the bot software. It should be a `SemVer` object.
241-
You can create a `SemVer` object using the `parseSemVer()` function:
240+
: The version of the bot software. It should be a string:
242241

243242
~~~~ typescript twoslash
244243
// @noErrors: 2345
245-
import { createBot, parseSemVer } from "@fedify/botkit";
244+
import { createBot } from "@fedify/botkit";
246245

247246
const bot = createBot<void>({
248247
// Omitted other options for brevity
249248
software: {
250249
name: "my-bot",
251-
version: parseSemVer("1.0.0"), // [!code highlight]
250+
version: "1.0.0", // [!code highlight]
252251
}
253252
});
254253
~~~~

docs/concepts/message.md

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -409,22 +409,19 @@ property. It is represented as a string, which is one of the following:
409409
### Language hint
410410

411411
You can get the language hint of the message through the `~Message.language`
412-
property. It is represented as a [`LanguageTag`] object. If you want just
413-
a BCP 47 language tag string, you can call the [`LanguageTag.compact()`] method:
412+
property. It is represented as an [`Intl.Locale`] object. If you want just
413+
a BCP 47 language tag string, you can call the [`Intl.Locale.toString()`]
414+
method:
414415

415416
~~~~ typescript twoslash
416417
import { type Message, type MessageClass } from "@fedify/botkit";
417418
const message = {} as unknown as Message<MessageClass, void>;
418419
// ---cut-before---
419-
message.language?.compact() // e.g., "en", "en-US", "zh-Hant"
420+
message.language?.toString() // e.g., "en", "en-US", "zh-Hant"
420421
~~~~
421422

422-
> [!TIP]
423-
> BotKit re-exports [`LanguageTag`] class and [`parseLanguageTag()`] function.
424-
425-
[`LanguageTag`]: https://phensley.github.io/cldr-engine/docs/en/api-languagetag
426-
[`LanguageTag.compact()`]: https://phensley.github.io/cldr-engine/docs/en/api-languagetag.html#compact
427-
[`parseLanguageTag()`]: https://phensley.github.io/cldr-engine/docs/en/api-cldrframework#parselanguagetag
423+
[`Intl.Locale`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale
424+
[`Intl.Locale.toString()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/toString
428425

429426
### Traversing the conversation
430427

@@ -560,7 +557,7 @@ the `~Message.raw` property:
560557

561558
~~~~ typescript twoslash
562559
import type { Message, MessageClass } from "@fedify/botkit";
563-
import { Place } from "@fedify/fedify/vocab";
560+
import { Place } from "@fedify/vocab";
564561
const message = {} as unknown as Message<MessageClass, void>;
565562
// ---cut-before---
566563
const location = await message.raw.getLocation();
@@ -575,14 +572,14 @@ In the above example, the [`Place`] class is declared by Fedify, so you need to
575572
install it and import it:
576573

577574
~~~~ typescript twoslash
578-
import { Place } from "@fedify/fedify/vocab";
575+
import { Place } from "@fedify/vocab";
579576
~~~~
580577

581-
[`Article`]: https://jsr.io/@fedify/fedify/doc/vocab/~/Article
582-
[`ChatMessage`]: https://jsr.io/@fedify/fedify/doc/vocab/~/ChatMessage
583-
[`Note`]: https://jsr.io/@fedify/fedify/doc/vocab/~/Note
584-
[`Question`]: https://jsr.io/@fedify/fedify/doc/vocab/~/Question
585-
[`Place`]: https://jsr.io/@fedify/fedify/doc/vocab/~/Place
578+
[`Article`]: https://jsr.io/@fedify/vocab/doc/~/Article
579+
[`ChatMessage`]: https://jsr.io/@fedify/vocab/doc/~/ChatMessage
580+
[`Note`]: https://jsr.io/@fedify/vocab/doc/~/Note
581+
[`Question`]: https://jsr.io/@fedify/vocab/doc/~/Question
582+
[`Place`]: https://jsr.io/@fedify/vocab/doc/~/Place
586583

587584

588585
Getting published messages

docs/deploy/deno-deploy.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,17 @@ Prerequisites
2727
deno install -gArf jsr:@deno/deployctl
2828
~~~~
2929

30-
4. Install the [Fedify] package to your bot project:
30+
4. Install the [Fedify] Deno KV adapter package to your bot project:
3131

3232
~~~~ sh
33-
deno add jsr:@fedify/fedify
33+
deno add jsr:@fedify/denokv
3434
~~~~
3535

3636
5. Configure your bot to use Deno KV for storage and message queue:
3737

3838
~~~~ typescript
3939
import { createBot } from "@fedify/botkit";
40-
import { DenoKvMessageQueue, DenoKvStore } from "@fedify/fedify/x/deno";
40+
import { DenoKvMessageQueue, DenoKvStore } from "@fedify/denokv";
4141

4242
const kv = await Deno.openKv();
4343

0 commit comments

Comments
 (0)