Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
939ab40
Initialize @fedify/uri-template package
2chanhaeng Apr 27, 2026
c775f25
Update version of @fedify/uri-template
2chanhaeng Apr 28, 2026
49c5a36
Add test for template
2chanhaeng Apr 28, 2026
e4a92cf
Allow **/*.bench.ts files use `@fedfiy/fixture`
2chanhaeng May 1, 2026
fb598fd
Implement RFC 6570 URI template expansion
2chanhaeng May 1, 2026
8aaa646
Add test suite for @fedify/uri-template Template
2chanhaeng May 1, 2026
c04c9ea
Report URI template expansion errors
2chanhaeng May 2, 2026
498c32c
Document URI template compatibility
2chanhaeng May 2, 2026
d9dd866
Refine URI template expansion internals
2chanhaeng May 4, 2026
e7a3cde
Add URI template matching
2chanhaeng May 4, 2026
f761349
Add test suite for URI template matching
2chanhaeng May 4, 2026
d7ddf3e
Add RFC 6570 Router class
2chanhaeng May 6, 2026
6eae88d
Add Router conformance tests
2chanhaeng May 6, 2026
210a918
Capture legacy Router failures
2chanhaeng May 6, 2026
c5519db
Reorganize uri-template into per-feature module layouts
2chanhaeng May 6, 2026
ca25410
Rename "symmetric" to "round-trip" in user-facing prose
2chanhaeng May 6, 2026
41db5d6
Rename router memory pressure scenario factories
2chanhaeng May 6, 2026
b6a7c5d
Document operator behavior table and drop dead constant
2chanhaeng May 6, 2026
507cd1a
Drop unused VariableSpec and align reporter docs with expansion
2chanhaeng May 6, 2026
9d857bd
Document route-shape gaps in uri-template-router compatibility test
2chanhaeng May 6, 2026
980cf79
Drop "using RegExp" qualifier from Template bench label
2chanhaeng May 6, 2026
a47ca29
Add Router#register, batch trie insert, and constructor routes
2chanhaeng May 7, 2026
5103d2b
Move URI template old tests
2chanhaeng May 8, 2026
6a33b2b
Group uri-template tests by suite via nested t.step
2chanhaeng May 8, 2026
3b90c01
Export `isExpression` from @fedify/uri-template
2chanhaeng May 8, 2026
8b75be4
Migrate @fedify/fedify to @fedify/uri-template router
2chanhaeng May 8, 2026
d41af4b
Note uri-template router migration in CHANGES.md
2chanhaeng May 8, 2026
1b8eabc
Export isPath helper from @fedify/uri-template
2chanhaeng May 8, 2026
2be104e
Tighten match backtracking bounds in @fedify/uri-template
2chanhaeng May 8, 2026
395132f
Replace match bench with backtracking-pressure cases
2chanhaeng May 8, 2026
199d100
Add PR link
2chanhaeng May 9, 2026
4e7b891
Export `assertPath` from @fedify/uri-template
2chanhaeng May 9, 2026
eb6cbf1
Replace `Router` from @fedify/fedify with the wrapper of `Router` fro…
2chanhaeng May 9, 2026
e876cac
Apply review feedback from PR #758
2chanhaeng May 9, 2026
d587135
Fix `consumeUnnamed` over-pruning of valid match decompositions
2chanhaeng May 9, 2026
cc3b507
Fix `defaultReporter`
2chanhaeng May 11, 2026
0565b7b
Tighten identifier path validation in FederationBuilder
2chanhaeng May 11, 2026
d7fb55b
Accept the empty path so trailing-slash retry can match `/`
2chanhaeng May 11, 2026
768c1a9
Polish naming and fixture comments in uri-template tests
2chanhaeng May 11, 2026
48aad17
Centralize expression parse error reporting in the tokenizer
2chanhaeng May 11, 2026
7b7bed4
Drop stale router trie entries on re-registration
2chanhaeng May 11, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,13 @@ To be released.
deliberately exclude raw URLs, query strings, and identifier values to
keep cardinality bounded. [[#316], [#736], [#757]]

- Replaced Fedify's internal federation routing with
*@fedify/uri-template* for stricter RFC 6570 URI Template expansion and
matching. The deprecated `Router` export from *@fedify/fedify* remains
available for compatibility. [[#418]]

[#316]: https://github.com/fedify-dev/fedify/issues/316
[#418]: https://github.com/fedify-dev/fedify/issues/418
[#619]: https://github.com/fedify-dev/fedify/issues/619
[#735]: https://github.com/fedify-dev/fedify/issues/735
[#736]: https://github.com/fedify-dev/fedify/issues/736
Expand All @@ -72,6 +78,15 @@ To be released.
- Added a `meterProvider` option to `createFederation()` so mock contexts can
expose a test OpenTelemetry meter provider. [[#316], [#619], [#755]]

### @fedify/uri-template

- Added *@fedify/uri-template*, a dependency-free RFC 6570 URI Template
implementation for expansion, variable extraction, and round-trip route
matching. This package replaces Fedify's previous direct use of
*url-template* and *uri-template-router*. [[#418], [#758] by ChanHaeng Lee]

[#758]: https://github.com/fedify-dev/fedify/pull/758

### @fedify/amqp

- Added `AmqpMessageQueue.getDepth()` for reporting queued, ready, and
Expand Down
5 changes: 5 additions & 0 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@
"urlpattern",
"uuidv7",
"valueparser",
"varspec",
"varname",
"varnames",
"varchar",
"varchars",
"Vinxi",
"vitepress",
"vtsls",
Expand Down
1 change: 1 addition & 0 deletions deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"./packages/sqlite",
"./packages/sveltekit",
"./packages/testing",
"./packages/uri-template",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical | 🏗️ Heavy lift

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Check that packages importing `@fedify/uri-template` have it in both deno.json and package.json

echo "=== Checking for imports of `@fedify/uri-template` ==="
# Find all TypeScript files importing from `@fedify/uri-template`
rg -l 'from ["\x27]@fedify/uri-template' --type=ts -g '!**/node_modules/**' -g '!**/dist/**'

echo -e "\n=== Checking package.json files for `@fedify/uri-template` dependency ==="
# Find package.json files that should have `@fedify/uri-template` as dependency
fd -t f '^package\.json$' packages/ -x sh -c 'if grep -q "@fedify/uri-template" "$1"; then echo "✓ $1 has `@fedify/uri-template`"; else echo "✗ $1 missing `@fedify/uri-template` (check if needed)"; fi' _ {}

echo -e "\n=== Checking deno.json files for `@fedify/uri-template` in imports ==="
# Find deno.json files in packages that might import `@fedify/uri-template`
fd -t f '^deno\.json$' packages/ -x sh -c 'if grep -q "@fedify/uri-template" "$1"; then echo "✓ $1 has `@fedify/uri-template`"; else echo "✗ $1 missing `@fedify/uri-template` (check if needed)"; fi' _ {}

Repository: fedify-dev/fedify

Length of output: 5341


🏁 Script executed:

# Check the deno.json mentioned in the review (appears to be root deno.json based on context)
head -40 deno.json

Repository: fedify-dev/fedify

Length of output: 1080


🏁 Script executed:

# Check packages/fedify/deno.json specifically
cat packages/fedify/deno.json

Repository: fedify-dev/fedify

Length of output: 3299


🏁 Script executed:

# Check packages/fedify/package.json to see how `@fedify/uri-template` is declared
cat packages/fedify/package.json

Repository: fedify-dev/fedify

Length of output: 5406


Add @fedify/uri-template to packages/fedify/deno.json imports.

The package imports from @fedify/uri-template (verified in 7 files) and correctly declares it in package.json, but it is missing from deno.json. Per the critical coding guideline: "Dependencies must be added to BOTH deno.json and package.json. Forgetting package.json will cause Node.js and Bun tests to fail with ERR_MODULE_NOT_FOUND." This omission will break Deno support.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@deno.json` at line 28, Add the missing dependency entry for
"@fedify/uri-template" to the deno.json imports array so Deno can resolve the
package; update the imports block (alongside the existing
"./packages/uri-template" entry) to include the mapping for
"@fedify/uri-template" matching the package declared in package.json so imports
that reference "@fedify/uri-template" across the codebase resolve correctly in
Deno.

"./packages/vocab",
"./packages/vocab-runtime",
"./packages/vocab-tools",
Expand Down
9 changes: 3 additions & 6 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions packages/fedify/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ Here is the list of packages:
| [@fedify/sqlite](/packages/sqlite/) | [JSR][jsr:@fedify/sqlite] | [npm][npm:@fedify/sqlite] | SQLite driver |
| [@fedify/sveltekit](/packages/sveltekit/) | [JSR][jsr:@fedify/sveltekit] | [npm][npm:@fedify/sveltekit] | SvelteKit integration |
| [@fedify/testing](/packages/testing/) | [JSR][jsr:@fedify/testing] | [npm][npm:@fedify/testing] | Testing utilities |
| [@fedify/uri-template](/packages/uri-template/) | [JSR][jsr:@fedify/uri-template] | [npm][npm:@fedify/uri-template] | RFC 6570 URI Template library |
| [@fedify/vocab](/packages/vocab/) | [JSR][jsr:@fedify/vocab] | [npm][npm:@fedify/vocab] | Activity Vocabulary library |
| [@fedify/vocab-runtime](/packages/vocab-runtime/) | [JSR][jsr:@fedify/vocab-runtime] | [npm][npm:@fedify/vocab-runtime] | Runtime library for code-generated vocab |
| [@fedify/vocab-tools](/packages/vocab-tools/) | [JSR][jsr:@fedify/vocab-tools] | [npm][npm:@fedify/vocab-tools] | Code generation tools for Activity Vocab |
Expand Down Expand Up @@ -176,6 +177,8 @@ Here is the list of packages:
[npm:@fedify/sveltekit]: https://www.npmjs.com/package/@fedify/sveltekit
[jsr:@fedify/testing]: https://jsr.io/@fedify/testing
[npm:@fedify/testing]: https://www.npmjs.com/package/@fedify/testing
[jsr:@fedify/uri-template]: https://jsr.io/@fedify/uri-template
[npm:@fedify/uri-template]: https://www.npmjs.com/package/@fedify/uri-template
[jsr:@fedify/vocab]: https://jsr.io/@fedify/vocab
[npm:@fedify/vocab]: https://www.npmjs.com/package/@fedify/vocab
[jsr:@fedify/vocab-runtime]: https://jsr.io/@fedify/vocab-runtime
Expand Down
4 changes: 1 addition & 3 deletions packages/fedify/deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@
"json-canon": "npm:json-canon@^1.0.1",
"jsonld": "npm:jsonld@^9.0.0",
"pkijs": "npm:pkijs@^3.3.3",
"structured-field-values": "npm:structured-field-values@^2.0.4",
"uri-template-router": "npm:uri-template-router@^1.0.0",
"url-template": "npm:url-template@^3.1.1"
"structured-field-values": "npm:structured-field-values@^2.0.4"
},
"exclude": [
".test-report.xml",
Expand Down
3 changes: 1 addition & 2 deletions packages/fedify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@
}
},
"dependencies": {
"@fedify/uri-template": "workspace:*",
"@fedify/vocab": "workspace:*",
"@fedify/vocab-runtime": "workspace:*",
"@fedify/webfinger": "workspace:*",
Expand All @@ -153,8 +154,6 @@
"json-canon": "^1.0.1",
"jsonld": "^9.0.0",
"structured-field-values": "^2.0.4",
"uri-template-router": "^1.0.0",
"url-template": "^3.1.1",
"urlpattern-polyfill": "catalog:"
},
"devDependencies": {
Expand Down
45 changes: 44 additions & 1 deletion packages/fedify/src/federation/builder.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { test } from "@fedify/fixture";
import { RouterError } from "@fedify/uri-template";
import { Activity, Note, Person } from "@fedify/vocab";
import { assertEquals, assertExists, assertThrows } from "@std/assert";
import type { Protocol } from "../nodeinfo/types.ts";
Expand All @@ -13,7 +14,6 @@ import type {
} from "./callback.ts";
import { MemoryKvStore } from "./kv.ts";
import type { FederationImpl } from "./middleware.ts";
import { RouterError } from "./router.ts";

test("FederationBuilder", async (t) => {
await t.step(
Expand Down Expand Up @@ -211,6 +211,27 @@ test("FederationBuilder", async (t) => {
),
RouterError,
);
assertThrows(
() =>
builderAfterInvalid.setOutboxListeners(
"/users/{identifier:3}/outbox" as `${string}{identifier}${string}`,
),
RouterError,
);
assertThrows(
() =>
builderAfterInvalid.setOutboxListeners(
"/users/{identifier*}/outbox" as `${string}{identifier}${string}`,
),
RouterError,
);
assertThrows(
() =>
builderAfterInvalid.setOutboxListeners(
"/users/{identifier,identifier}/outbox" as `${string}{identifier}${string}`,
),
RouterError,
);
builderAfterInvalid.setOutboxListeners("/users/{identifier}/outbox");

const builder2 = createFederationBuilder<void>();
Expand All @@ -231,6 +252,18 @@ test("FederationBuilder", async (t) => {
RouterError,
);

const builder3a = createFederationBuilder<void>();
assertThrows(
() => builder3a.setOutboxListeners("/users{;identifier}/outbox"),
RouterError,
);

const builder3b = createFederationBuilder<void>();
assertThrows(
() => builder3b.setOutboxListeners("/users{.identifier}/outbox"),
RouterError,
);

const builder4 = createFederationBuilder<void>();
assertThrows(
() =>
Expand All @@ -240,6 +273,16 @@ test("FederationBuilder", async (t) => {
),
RouterError,
);

const builder5 = createFederationBuilder<void>();
assertThrows(
() =>
builder5.setOutboxDispatcher(
"/users/{identifier:3}/outbox" as `${string}{identifier}${string}`,
() => ({ items: [] }),
),
RouterError,
);
});

await t.step("should pass build options correctly", async () => {
Expand Down
Loading
Loading