mirror of
https://github.com/navidrome/navidrome.git
synced 2026-07-09 17:18:45 +00:00
* feat(plugins): add public Track and Artist DTOs for host services
* feat(plugins): add Matcher host-service interface and MatchSong DTO
* feat(plugins): generate Matcher host wrappers, PDK clients, and matcher permission
* feat(plugins): implement Matcher host service and MediaFile-to-Track converter
Also fixes an ndpgen bug where ParseDirectory parsed each host-service file
in isolation, so a service method referencing a struct defined in another
file of the same package (host.Track in track.go) could not be resolved.
ParseDirectory now collects package-wide structs in a first pass, mirroring
ParseCapabilities; PDK clients regenerated cleanly via make gen.
* feat(plugins): register Matcher host service in the manager
* test(plugins): add Matcher host service integration test plugin
* refactor(plugins): simplify matcher converter and parser file collection
- toTrack: use gg.V for nil-able field derefs and slice.Map for genres/
participants, removing the repeated nil-guard blocks and inner loop
- manager_loader: drop the redundant ds==nil guard (loadEnabledPlugins
already gates a nil DataStore), matching the other service entries
- ndpgen parser: extract collectGoFiles, shared by ParseDirectory and
ParseCapabilities instead of duplicating the file-filter loop
* fix(plugins): keep nullable Track numerics as pointers
ReplayGain values, BitDepth, and BPM are nullable in model.MediaFile, and 0
is a valid measured ReplayGain value. Flattening them to value types with
omitempty made a real 0 indistinguishable from absent. Model them as *float64
/*int32 so plugins can tell 'no data' from a measured 0. Regenerated PDK
clients; converter passes the model pointers through (RG) or maps *int->*int32
(BitDepth/BPM).
* refactor(plugins): trim redundant pass labels in ndpgen ParseDirectory
The function doc already explains the two-pass approach; the inline labels
restated it. Reduce to bare waypoints.
* fix(plugins): gate Track.Path on library filesystem permission
MatchSongs copied mf.Path into every result unconditionally, letting a plugin
with only the matcher permission enumerate on-disk file paths by matching known
songs. Gate Path behind library.filesystem, matching the Library host service.
toTrack is now a method carrying the permission flag.
* refactor(plugins): align MatchSong JSON casing and parse Go files once
- MatchSong: artistMBID/albumMBID JSON tags -> artistMbid/albumMbid so the Go
wire format matches the Rust SDK's camelCase serialization (cross-SDK fix)
- MatchSongs doc reworded to language-neutral 'empty (absent)' so generated
Rust/Python client docs no longer say Go-specific 'nil'
- ndpgen: parse each package file once (parseGoFiles) and reuse the ASTs across
both passes in ParseDirectory and ParseCapabilities, instead of re-parsing
* refactor(plugins): use shared types for Matcher host service
Move the Matcher host service onto the shared plugins/types package instead
of the host-local MatchSong and Track structs. MatchSongs now takes
[]types.SongRef and returns []*types.Track, dropping host.MatchSong and moving
host.Track (with its host.Artist dependency collapsed onto types.ArtistRef) into
plugins/types. ArtistRef gains SortName and SubRole so it can back a track's
Participants.
SongRef gains a millisecond-precision DurationMs field that supersedes the now
deprecated seconds-based Duration, with DurationInMs() resolving the effective
value and SetDurationMs() keeping both fields in sync when populating a SongRef
to send to a plugin.
The ndpgen host-wrapper template only ever imported context, json and extism, so
a host service referencing the shared types package produced uncompilable code.
Emit the plugins/types import when the service references shared types directly
(gated on the existing Service.ImportsSharedTypes), matching the client template,
and cover it with GenerateHost tests. This removes the need for host-local
re-export aliases. Regenerated the Go/Rust/Python PDK and capability schemas
accordingly.
* test(plugins): cover SongRef duration and artist conversion
Add unit coverage for the new SongRef behavior: SetDurationMs populating both
DurationMs and the deprecated seconds field, and the SongRef-to-agents.Song
conversion preferring DurationMs over Duration and the Artists list over the
scalar Artist/ArtistMBID.
Extract the inline SongRef-to-agents.Song closure in MatchSongs into a named
toAgentSong function so the conversion can be asserted directly rather than only
through the opaque matcher. The end-to-end wire shape of the moved types is
already validated by the existing MatcherService integration test, so no new
WASM-boundary test is needed.
* fix(plugins): harden and unify SongRef-to-agents.Song duration conversion
Address findings from a code review of the matcher host service:
- DurationInMs now clamps a negative deprecated-seconds value to 0 instead of
converting it through uint32, which previously wrapped a value like -1s into a
~49-day duration that corrupted the matcher's duration-proximity tiebreaker.
- Replace the unused SetDurationMs(uint32) with SetDuration(seconds float32),
which takes the unit callers actually hold (model.MediaFile.Duration is
float32 seconds) and centralizes the seconds-to-ms conversion. Wire it into
mediaFileToSongRef so outbound SongRefs carry both duration fields in sync.
- Make the metadata-agent path use DurationInMs() so every consumer of the
shared SongRef honors the DurationMs-over-Duration precedence contract; a
plugin sending only DurationMs no longer loses its duration on that path.
- Collapse the matcher's duplicate toAgentSong/agentArtists helpers into the
existing songRefToAgentSong converter, so there is a single SongRef-to-Song
mapping. Tests narrowed to the duration cases, with artist precedence still
covered in metadata_agent_test.go.
* feat(plugins): allow Matcher host service to scope a match to a user
Add an options struct to the Matcher host service so a plugin can run a match as
a specific user. When MatchOptions.Username is set, the match is run in that
user's context: their favourites and ratings inform the matcher's tiebreaker, and
the returned tracks carry that user's per-user annotations (Starred, StarredAt,
Rating, PlayCount, PlayDate, added to types.Track). An empty username preserves
the previous unscoped behaviour.
Cross-user access is gated by the same allowedUsers/allUsers permission the Users
and SubsonicAPI host services use: an unknown username, or one the plugin is not
permitted to act as, returns an error. User-library access applies automatically
once the user is in context (applyLibraryFilter). Independently, results are now
restricted to the libraries the plugin itself may access via the precomputed
libraryAccess set, dropping any matched track outside that set (the input index
stays unmatched) — this applies even without a username and even for an
admin-scoped user.
core/matcher is unchanged: it already loads and uses annotations and applies
user-library filtering from context, so the feature works by deriving the request
context and post-filtering by plugin library access in the host adapter. The new
opts parameter and the Track annotation fields are propagated to all PDK clients
(Go/Rust/Python) by make gen.
* fix(plugins): correct Matcher library scope and unify user-access checks
Address findings from a code review of the user-scoped Matcher host service:
- The plugin-library post-filter previously dropped every match for a plugin that
holds only the matcher permission, because library config is tied to the Library
permission and a matcher-only plugin has none (empty allowedLibraries,
AllLibraries=false). Gate the filter on whether the plugin actually declared the
Library permission: matcher-only plugins are no longer library-restricted, while
plugins that opt into a library scope are enforced as before. The per-user
library filter (applyLibraryFilter) still applies whenever a non-admin user is
scoped.
- resolveUser collapsed every FindByUsername error (including transient DB
failures) into a misleading "not found". Extract a shared userAccess type
(alongside libraryAccess) whose resolve() distinguishes model.ErrNotFound from a
real backend error and authorizes the user against the allowed set. The Matcher
service now uses it, and host_subsonicapi shares the same userAccess type for its
permission check (preserving its existing error messages), removing a third
divergent copy of the resolve-and-authorize logic.
- Document in the matcher tests that the mock MediaFileRepo returns annotations
unconditionally, so the unit tests cover the adapter's scoped-flag gating and
access checks but not the SQL per-user join. Add tests for the library-permission
gating and for surfacing a backend error instead of masking it as not-found.
* fix(plugins): require a library scope for Matcher, fail closed
Reverse the permissive default introduced when fixing the library post-filter: a
Matcher plugin now must be granted a library scope (all libraries, or at least one
specific library) and MatchSongs rejects the request with "no libraries
configured" when it has none, instead of either silently matching nothing or
defaulting to every library.
This mirrors how the SubsonicAPI host service requires a user scope
(checkPermissions errors with "no users configured" when none is set): the check
is a runtime guard via libraryAccess.configured(), needs no manifest changes, and
keeps the failure loud rather than silent. The per-match library post-filter then
always applies, and the restrictLibraries flag added in the previous commit is
removed.
* fix(plugins): require library permission for matcher; guard nil user
Close the gap where a plugin declaring only the matcher permission loaded
successfully but failed every MatchSongs call with "no libraries configured",
with no way for an admin to grant a library scope (the library-config UI is gated
on the library permission). Add a cross-field manifest rule, mirroring the
existing "subsonicapi requires users" rule, so the matcher permission requires
the library permission to be declared. A matcher plugin therefore also surfaces
the library-config panel and is subject to the existing load/enable-time library
configuration gate, making the fail-closed library check reachable and fixable
rather than a silent dead end. The test plugin manifest now declares the library
permission accordingly.
Also restore a defensive nil-user guard in userAccess.resolve: if a DataStore's
FindByUsername ever returns (nil, nil) instead of model.ErrNotFound, return a
clean "not found" error rather than dereferencing a nil *model.User.
* feat(plugins): expose track AverageRating in Matcher results
Add AverageRating to the Matcher's Track DTO. Unlike the per-user annotations
(Starred, Rating, PlayCount, ...), AverageRating is an aggregate stored on the
track itself and is loaded regardless of the request user, so it is populated
unconditionally rather than gated on a scoped username. Propagated to the PDK
types by make gen.
Signed-off-by: Deluan <deluan@navidrome.org>
* style(plugins): trim verbose comments in matcher host service
Condense the over-long explanatory comments added across the matcher host
service to one-liners that state the why, and simplify the ptrInt32/unixPtr
helpers to Go 1.26's new(value). No behavior change.
* refactor(plugins): pass userAccess into newSubsonicAPIService
Move newUserAccess construction to the loader call site so the SubsonicAPI service
constructor takes a userAccess value directly, matching newMatcherService. Pure
refactor: the service already stored a userAccess internally, so behavior and error
messages are unchanged.
* fix(plugins): regenerate PDK and drop omitempty from AverageRating
Re-run make gen so the generated PDK doc comments match the source comment
trimmed in an earlier commit (the source was simplified but the PDK was not
regenerated, leaving the committed files stale — a 'generated files up to date'
hazard).
Also drop omitempty from Track.AverageRating: it is always set (0 when unrated),
so it should be present in the payload like the other always-set fields
(BirthTime/CreatedAt/UpdatedAt), not dropped at zero. Tag change propagated to the
PDK by the same regeneration.
* fix(plugins): reject user-scoped match before lookup when plugin has no user scope
A matcher plugin requires the library permission but not the users permission, so
a matcher-only plugin always has an empty user scope (allUsers=false, no allowed
users). MatchSongs still ran FindByUsername for any opts.Username before checking
authorization and returned distinguishable errors ('user X not found' vs 'not
allowed to act as user X'), letting such a plugin enumerate account names from the
error text.
Guard userAccess.resolve to reject with a single fixed error before the lookup when
the plugin has no user scope, mirroring how the SubsonicAPI service short-circuits
with 'no users configured'. The unscoped match path (no username) is unaffected, so
matcher-only plugins still match normally.
* fix(plugins): run unscoped matcher as admin, not the inherited request user
A matcher host call can arrive on a context that already carries a request user
(e.g. a plugin capability invoked while serving that user's request — extism
propagates the call context into host functions). With no opts.Username, MatchSongs
passed that context straight through, so the media-file repository applied the
caller's library filter and per-user annotation ranking to an explicitly unscoped
match.
Set the user context explicitly: a username scopes to that user (overriding any
inherited one), and an unscoped match runs under adminContext so only the plugin's
own library scope constrains results. Adds tests using a context-capturing
DataStore to assert the user the matcher resolves in both cases.
* chore(plugins): drop the generated Python matcher PDK
The Python plugin PDK is no longer supported (ndpgen generates only Go and Rust
clients), so remove the stale generated nd_host_matcher.py rather than leave a
client that drifts from the host interface.
* docs(plugins): deprecate SongRef.Artist/ArtistMBID in favor of Artists
Mark the scalar single-artist fields deprecated; Artists (the ArtistRef list) is
the preferred way to supply artist data and already takes precedence for matching.
Propagated to the PDK and capability schemas by make gen.
* refactor(plugins): flatten Track.Participants and add Role to ArtistRef
Change Track.Participants from map[role][]ArtistRef to a flat []ArtistRef, and give
ArtistRef a Role field (the participation category: artist/composer/performer/...)
alongside SubRole (a specialization within a role, e.g. the instrument for a
performer). In the flat list each entry now self-describes its role rather than
relying on a map key, matching how SongRef.Artists is already a flat list; the
converter tags each entry with its role and emits them in a stable role order.
Propagated to the PDK and capability schemas by make gen.
---------
Signed-off-by: Deluan <deluan@navidrome.org>
853 lines
25 KiB
Go
853 lines
25 KiB
Go
package internal
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
|
|
. "github.com/onsi/ginkgo/v2"
|
|
. "github.com/onsi/gomega"
|
|
)
|
|
|
|
var _ = Describe("Parser", func() {
|
|
var tmpDir string
|
|
|
|
BeforeEach(func() {
|
|
var err error
|
|
tmpDir, err = os.MkdirTemp("", "ndpgen-test-*")
|
|
Expect(err).NotTo(HaveOccurred())
|
|
})
|
|
|
|
AfterEach(func() {
|
|
os.RemoveAll(tmpDir)
|
|
})
|
|
|
|
Describe("ParseDirectory", func() {
|
|
It("should parse a simple host service interface", func() {
|
|
src := `package host
|
|
|
|
import "context"
|
|
|
|
// SubsonicAPIService provides access to Navidrome's Subsonic API.
|
|
//nd:hostservice name=SubsonicAPI permission=subsonicapi
|
|
type SubsonicAPIService interface {
|
|
// Call executes a Subsonic API request.
|
|
//nd:hostfunc
|
|
Call(ctx context.Context, uri string) (response string, err error)
|
|
}
|
|
`
|
|
err := os.WriteFile(filepath.Join(tmpDir, "service.go"), []byte(src), 0600)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
services, err := ParseDirectory(tmpDir)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(services).To(HaveLen(1))
|
|
|
|
svc := services[0]
|
|
Expect(svc.Name).To(Equal("SubsonicAPI"))
|
|
Expect(svc.Permission).To(Equal("subsonicapi"))
|
|
Expect(svc.Interface).To(Equal("SubsonicAPIService"))
|
|
Expect(svc.Methods).To(HaveLen(1))
|
|
|
|
m := svc.Methods[0]
|
|
Expect(m.Name).To(Equal("Call"))
|
|
Expect(m.HasError).To(BeTrue())
|
|
Expect(m.Params).To(HaveLen(1))
|
|
Expect(m.Params[0].Name).To(Equal("uri"))
|
|
Expect(m.Params[0].Type).To(Equal("string"))
|
|
Expect(m.Returns).To(HaveLen(1))
|
|
Expect(m.Returns[0].Name).To(Equal("response"))
|
|
Expect(m.Returns[0].Type).To(Equal("string"))
|
|
})
|
|
|
|
It("should parse multiple methods", func() {
|
|
src := `package host
|
|
|
|
import "context"
|
|
|
|
// SchedulerService provides scheduling capabilities.
|
|
//nd:hostservice name=Scheduler permission=scheduler
|
|
type SchedulerService interface {
|
|
//nd:hostfunc
|
|
ScheduleRecurring(ctx context.Context, cronExpression string) (scheduleID string, err error)
|
|
|
|
//nd:hostfunc
|
|
ScheduleOneTime(ctx context.Context, delaySeconds int32) (scheduleID string, err error)
|
|
|
|
//nd:hostfunc
|
|
CancelSchedule(ctx context.Context, scheduleID string) (canceled bool, err error)
|
|
}
|
|
`
|
|
err := os.WriteFile(filepath.Join(tmpDir, "scheduler.go"), []byte(src), 0600)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
services, err := ParseDirectory(tmpDir)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(services).To(HaveLen(1))
|
|
|
|
svc := services[0]
|
|
Expect(svc.Name).To(Equal("Scheduler"))
|
|
Expect(svc.Methods).To(HaveLen(3))
|
|
|
|
Expect(svc.Methods[0].Name).To(Equal("ScheduleRecurring"))
|
|
Expect(svc.Methods[0].Params[0].Type).To(Equal("string"))
|
|
|
|
Expect(svc.Methods[1].Name).To(Equal("ScheduleOneTime"))
|
|
Expect(svc.Methods[1].Params[0].Type).To(Equal("int32"))
|
|
|
|
Expect(svc.Methods[2].Name).To(Equal("CancelSchedule"))
|
|
Expect(svc.Methods[2].Returns[0].Type).To(Equal("bool"))
|
|
})
|
|
|
|
It("should skip methods without hostfunc annotation", func() {
|
|
src := `package host
|
|
|
|
import "context"
|
|
|
|
//nd:hostservice name=Test permission=test
|
|
type TestService interface {
|
|
//nd:hostfunc
|
|
Exported(ctx context.Context) error
|
|
|
|
// This method is not exported
|
|
NotExported(ctx context.Context) error
|
|
}
|
|
`
|
|
err := os.WriteFile(filepath.Join(tmpDir, "test.go"), []byte(src), 0600)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
services, err := ParseDirectory(tmpDir)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(services).To(HaveLen(1))
|
|
Expect(services[0].Methods).To(HaveLen(1))
|
|
Expect(services[0].Methods[0].Name).To(Equal("Exported"))
|
|
})
|
|
|
|
It("should handle custom export name", func() {
|
|
src := `package host
|
|
|
|
import "context"
|
|
|
|
//nd:hostservice name=Test permission=test
|
|
type TestService interface {
|
|
//nd:hostfunc name=custom_export_name
|
|
MyMethod(ctx context.Context) error
|
|
}
|
|
`
|
|
err := os.WriteFile(filepath.Join(tmpDir, "test.go"), []byte(src), 0600)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
services, err := ParseDirectory(tmpDir)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(services[0].Methods[0].ExportName).To(Equal("custom_export_name"))
|
|
Expect(services[0].Methods[0].FunctionName("test")).To(Equal("custom_export_name"))
|
|
})
|
|
|
|
It("should skip generated files", func() {
|
|
regularSrc := `package host
|
|
|
|
import "context"
|
|
|
|
//nd:hostservice name=Test permission=test
|
|
type TestService interface {
|
|
//nd:hostfunc
|
|
Method(ctx context.Context) error
|
|
}
|
|
`
|
|
genSrc := `// Code generated. DO NOT EDIT.
|
|
package host
|
|
|
|
//nd:hostservice name=Generated permission=gen
|
|
type GeneratedService interface {
|
|
//nd:hostfunc
|
|
Method() error
|
|
}
|
|
`
|
|
err := os.WriteFile(filepath.Join(tmpDir, "test.go"), []byte(regularSrc), 0600)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
err = os.WriteFile(filepath.Join(tmpDir, "test_gen.go"), []byte(genSrc), 0600)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
services, err := ParseDirectory(tmpDir)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(services).To(HaveLen(1))
|
|
Expect(services[0].Name).To(Equal("Test"))
|
|
})
|
|
|
|
It("should skip interfaces without hostservice annotation", func() {
|
|
src := `package host
|
|
|
|
import "context"
|
|
|
|
// Regular interface without annotation
|
|
type RegularInterface interface {
|
|
Method(ctx context.Context) error
|
|
}
|
|
|
|
//nd:hostservice name=Annotated permission=annotated
|
|
type AnnotatedService interface {
|
|
//nd:hostfunc
|
|
Method(ctx context.Context) error
|
|
}
|
|
`
|
|
err := os.WriteFile(filepath.Join(tmpDir, "test.go"), []byte(src), 0600)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
services, err := ParseDirectory(tmpDir)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(services).To(HaveLen(1))
|
|
Expect(services[0].Name).To(Equal("Annotated"))
|
|
})
|
|
|
|
It("should return empty slice for directory with no host services", func() {
|
|
src := `package host
|
|
|
|
type RegularInterface interface {
|
|
Method() error
|
|
}
|
|
`
|
|
err := os.WriteFile(filepath.Join(tmpDir, "test.go"), []byte(src), 0600)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
services, err := ParseDirectory(tmpDir)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(services).To(BeEmpty())
|
|
})
|
|
|
|
It("should resolve structs defined in a sibling file of the same package", func() {
|
|
// types.go defines Track and Artist — no host service here
|
|
typesSrc := `package host
|
|
|
|
// Artist is a track participant.
|
|
type Artist struct {
|
|
// ID is the artist identifier.
|
|
ID string ` + "`json:\"id\"`" + `
|
|
// Name is the artist name.
|
|
Name string ` + "`json:\"name\"`" + `
|
|
}
|
|
|
|
// Track is a media file projection.
|
|
type Track struct {
|
|
// ID is the track identifier.
|
|
ID string ` + "`json:\"id\"`" + `
|
|
// Title is the track title.
|
|
Title string ` + "`json:\"title\"`" + `
|
|
// Participants maps role to artists (transitive dependency test).
|
|
Participants map[string][]Artist ` + "`json:\"participants\"`" + `
|
|
}
|
|
`
|
|
// service.go defines the host service that references Track from types.go
|
|
serviceSrc := `package host
|
|
|
|
import "context"
|
|
|
|
// MatcherService matches tracks.
|
|
//nd:hostservice name=Matcher permission=matcher
|
|
type MatcherService interface {
|
|
// MatchTrack finds a matching track.
|
|
//nd:hostfunc
|
|
MatchTrack(ctx context.Context, t Track) (matched bool, err error)
|
|
}
|
|
`
|
|
err := os.WriteFile(filepath.Join(tmpDir, "types.go"), []byte(typesSrc), 0600)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
err = os.WriteFile(filepath.Join(tmpDir, "service.go"), []byte(serviceSrc), 0600)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
services, err := ParseDirectory(tmpDir)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(services).To(HaveLen(1))
|
|
|
|
svc := services[0]
|
|
Expect(svc.Name).To(Equal("Matcher"))
|
|
Expect(svc.Methods).To(HaveLen(1))
|
|
Expect(svc.Methods[0].Name).To(Equal("MatchTrack"))
|
|
|
|
// Track must be resolved from the sibling file, not just the service file.
|
|
// Artist must also be transitively resolved (Track.Participants references it).
|
|
structNames := make([]string, len(svc.Structs))
|
|
for i, s := range svc.Structs {
|
|
structNames[i] = s.Name
|
|
}
|
|
Expect(structNames).To(ConsistOf("Track", "Artist"))
|
|
})
|
|
|
|
It("returns an error when a shared-type alias cannot be resolved (no registry)", func() {
|
|
fileA := `package host
|
|
|
|
import "github.com/navidrome/navidrome/plugins/types"
|
|
|
|
type TrackInfo = types.TrackInfo
|
|
`
|
|
fileB := `package host
|
|
|
|
import "context"
|
|
|
|
//nd:hostservice name=Matcher permission=matcher
|
|
type MatcherService interface {
|
|
//nd:hostfunc
|
|
Match(ctx context.Context, t TrackInfo) (bool, error)
|
|
}
|
|
`
|
|
Expect(os.WriteFile(filepath.Join(tmpDir, "aliases.go"), []byte(fileA), 0600)).To(Succeed())
|
|
Expect(os.WriteFile(filepath.Join(tmpDir, "matcher.go"), []byte(fileB), 0600)).To(Succeed())
|
|
|
|
_, err := ParseDirectoryWithShared(tmpDir, nil)
|
|
Expect(err).To(HaveOccurred())
|
|
Expect(err.Error()).To(ContainSubstring("TrackInfo"))
|
|
Expect(err.Error()).To(ContainSubstring("-shared"))
|
|
})
|
|
|
|
It("resolves shared-type aliases declared in a sibling file (package-wide alias map)", func() {
|
|
// File A: declares the shared-type alias in the same package
|
|
fileA := `package host
|
|
|
|
import "github.com/navidrome/navidrome/plugins/types"
|
|
|
|
// Deprecated: use types.Track.
|
|
type Track = types.Track
|
|
`
|
|
// File B: declares the host service that references Track from file A
|
|
fileB := `package host
|
|
|
|
import "context"
|
|
|
|
//nd:hostservice name=Matcher permission=matcher
|
|
type MatcherService interface {
|
|
//nd:hostfunc
|
|
MatchSongs(ctx context.Context, query string) (results []Track, err error)
|
|
}
|
|
`
|
|
Expect(os.WriteFile(filepath.Join(tmpDir, "aliases.go"), []byte(fileA), 0600)).To(Succeed())
|
|
Expect(os.WriteFile(filepath.Join(tmpDir, "matcher.go"), []byte(fileB), 0600)).To(Succeed())
|
|
|
|
shared := map[string]StructDef{
|
|
"Track": {
|
|
Name: "Track",
|
|
Fields: []FieldDef{
|
|
{Name: "Title", Type: "string", JSONTag: "title"},
|
|
{Name: "Artist", Type: "string", JSONTag: "artist"},
|
|
},
|
|
},
|
|
}
|
|
|
|
services, err := ParseDirectoryWithShared(tmpDir, shared)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(services).To(HaveLen(1))
|
|
|
|
byName := map[string]SharedAlias{}
|
|
for _, a := range services[0].SharedAliases {
|
|
byName[a.Name] = a
|
|
}
|
|
// Track alias is in a sibling file — must be resolved package-wide
|
|
Expect(byName).To(HaveKey("Track"))
|
|
Expect(byName["Track"].Target).To(Equal("types.Track"))
|
|
})
|
|
})
|
|
|
|
Describe("parseKeyValuePairs", func() {
|
|
It("should parse key=value pairs", func() {
|
|
result := parseKeyValuePairs("name=Test permission=test")
|
|
Expect(result).To(HaveKeyWithValue("name", "Test"))
|
|
Expect(result).To(HaveKeyWithValue("permission", "test"))
|
|
})
|
|
|
|
It("should return nil for empty input", func() {
|
|
result := parseKeyValuePairs("")
|
|
Expect(result).To(BeNil())
|
|
})
|
|
})
|
|
|
|
Describe("typeToString", func() {
|
|
It("should handle basic types", func() {
|
|
src := `package test
|
|
type T interface {
|
|
Method(s string, i int, b bool) ([]byte, error)
|
|
}
|
|
`
|
|
err := os.WriteFile(filepath.Join(tmpDir, "types.go"), []byte(src), 0600)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
// Parse and verify type conversion works
|
|
// This is implicitly tested through ParseDirectory
|
|
})
|
|
|
|
It("should convert interface{} to any", func() {
|
|
src := `package test
|
|
|
|
import "context"
|
|
|
|
//nd:hostservice name=Test permission=test
|
|
type TestService interface {
|
|
//nd:hostfunc
|
|
GetMetadata(ctx context.Context) (data map[string]interface{}, err error)
|
|
}
|
|
`
|
|
err := os.WriteFile(filepath.Join(tmpDir, "test.go"), []byte(src), 0600)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
services, err := ParseDirectory(tmpDir)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(services).To(HaveLen(1))
|
|
Expect(services[0].Methods[0].Returns[0].Type).To(Equal("map[string]any"))
|
|
})
|
|
})
|
|
|
|
Describe("Method helpers", func() {
|
|
It("should generate correct function names", func() {
|
|
m := Method{Name: "Call"}
|
|
Expect(m.FunctionName("subsonicapi")).To(Equal("subsonicapi_call"))
|
|
|
|
m.ExportName = "custom_name"
|
|
Expect(m.FunctionName("subsonicapi")).To(Equal("custom_name"))
|
|
})
|
|
|
|
It("should generate correct type names", func() {
|
|
m := Method{Name: "Call"}
|
|
// Host-side types are public
|
|
Expect(m.RequestTypeName("SubsonicAPI")).To(Equal("SubsonicAPICallRequest"))
|
|
Expect(m.ResponseTypeName("SubsonicAPI")).To(Equal("SubsonicAPICallResponse"))
|
|
// Client/PDK types are private
|
|
Expect(m.ClientRequestTypeName("SubsonicAPI")).To(Equal("subsonicAPICallRequest"))
|
|
Expect(m.ClientResponseTypeName("SubsonicAPI")).To(Equal("subsonicAPICallResponse"))
|
|
})
|
|
})
|
|
|
|
Describe("Service helpers", func() {
|
|
It("should generate correct output file name", func() {
|
|
s := Service{Name: "SubsonicAPI"}
|
|
Expect(s.OutputFileName()).To(Equal("subsonicapi_gen.go"))
|
|
})
|
|
|
|
It("should generate correct export prefix", func() {
|
|
s := Service{Name: "SubsonicAPI"}
|
|
Expect(s.ExportPrefix()).To(Equal("subsonicapi"))
|
|
})
|
|
})
|
|
|
|
Describe("ParseCapabilities", func() {
|
|
It("should parse a simple capability interface", func() {
|
|
src := `package capabilities
|
|
|
|
// MetadataAgent provides metadata retrieval.
|
|
//nd:capability name=metadata
|
|
type MetadataAgent interface {
|
|
// GetArtistBiography returns artist biography.
|
|
//nd:export name=nd_get_artist_biography
|
|
GetArtistBiography(ArtistInput) (ArtistBiographyOutput, error)
|
|
}
|
|
|
|
// ArtistInput is the input for artist-related functions.
|
|
type ArtistInput struct {
|
|
// ID is the artist ID.
|
|
ID string ` + "`json:\"id\"`" + `
|
|
// Name is the artist name.
|
|
Name string ` + "`json:\"name\"`" + `
|
|
}
|
|
|
|
// ArtistBiographyOutput is the output for GetArtistBiography.
|
|
type ArtistBiographyOutput struct {
|
|
// Biography is the biography text.
|
|
Biography string ` + "`json:\"biography\"`" + `
|
|
}
|
|
`
|
|
err := os.WriteFile(filepath.Join(tmpDir, "metadata.go"), []byte(src), 0600)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
capabilities, err := ParseCapabilities(tmpDir)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(capabilities).To(HaveLen(1))
|
|
|
|
cap := capabilities[0]
|
|
Expect(cap.Name).To(Equal("metadata"))
|
|
Expect(cap.Interface).To(Equal("MetadataAgent"))
|
|
Expect(cap.Required).To(BeFalse())
|
|
Expect(cap.Doc).To(ContainSubstring("MetadataAgent provides metadata retrieval"))
|
|
Expect(cap.Methods).To(HaveLen(1))
|
|
|
|
m := cap.Methods[0]
|
|
Expect(m.Name).To(Equal("GetArtistBiography"))
|
|
Expect(m.ExportName).To(Equal("nd_get_artist_biography"))
|
|
Expect(m.Input.Type).To(Equal("ArtistInput"))
|
|
Expect(m.Output.Type).To(Equal("ArtistBiographyOutput"))
|
|
|
|
// Check structs were collected
|
|
Expect(cap.Structs).To(HaveLen(2))
|
|
})
|
|
|
|
It("should parse a required capability", func() {
|
|
src := `package capabilities
|
|
|
|
// Scrobbler requires all methods to be implemented.
|
|
//nd:capability name=scrobbler required=true
|
|
type Scrobbler interface {
|
|
//nd:export name=nd_scrobbler_is_authorized
|
|
IsAuthorized(AuthInput) (AuthOutput, error)
|
|
|
|
//nd:export name=nd_scrobbler_scrobble
|
|
Scrobble(ScrobbleInput) (ScrobblerOutput, error)
|
|
}
|
|
|
|
type AuthInput struct {
|
|
UserID string ` + "`json:\"userId\"`" + `
|
|
}
|
|
|
|
type AuthOutput struct {
|
|
Authorized bool ` + "`json:\"authorized\"`" + `
|
|
}
|
|
|
|
type ScrobbleInput struct {
|
|
UserID string ` + "`json:\"userId\"`" + `
|
|
}
|
|
|
|
type ScrobblerOutput struct {
|
|
Error *string ` + "`json:\"error,omitempty\"`" + `
|
|
}
|
|
`
|
|
err := os.WriteFile(filepath.Join(tmpDir, "scrobbler.go"), []byte(src), 0600)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
capabilities, err := ParseCapabilities(tmpDir)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(capabilities).To(HaveLen(1))
|
|
|
|
cap := capabilities[0]
|
|
Expect(cap.Name).To(Equal("scrobbler"))
|
|
Expect(cap.Required).To(BeTrue())
|
|
Expect(cap.Methods).To(HaveLen(2))
|
|
})
|
|
|
|
It("should parse type aliases and consts", func() {
|
|
src := `package capabilities
|
|
|
|
//nd:capability name=scrobbler required=true
|
|
type Scrobbler interface {
|
|
//nd:export name=nd_scrobble
|
|
Scrobble(ScrobbleInput) (ScrobblerOutput, error)
|
|
}
|
|
|
|
type ScrobbleInput struct {
|
|
UserID string ` + "`json:\"userId\"`" + `
|
|
}
|
|
|
|
// ScrobblerErrorType indicates error handling behavior.
|
|
type ScrobblerErrorType string
|
|
|
|
const (
|
|
// ScrobblerErrorNone indicates no error.
|
|
ScrobblerErrorNone ScrobblerErrorType = "none"
|
|
// ScrobblerErrorRetry indicates retry later.
|
|
ScrobblerErrorRetry ScrobblerErrorType = "retry"
|
|
)
|
|
|
|
type ScrobblerOutput struct {
|
|
ErrorType *ScrobblerErrorType ` + "`json:\"errorType,omitempty\"`" + `
|
|
}
|
|
`
|
|
err := os.WriteFile(filepath.Join(tmpDir, "scrobbler.go"), []byte(src), 0600)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
capabilities, err := ParseCapabilities(tmpDir)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(capabilities).To(HaveLen(1))
|
|
|
|
cap := capabilities[0]
|
|
// Type alias should be collected
|
|
Expect(cap.TypeAliases).To(HaveLen(1))
|
|
Expect(cap.TypeAliases[0].Name).To(Equal("ScrobblerErrorType"))
|
|
Expect(cap.TypeAliases[0].Type).To(Equal("string"))
|
|
|
|
// Consts should be collected
|
|
Expect(cap.Consts).To(HaveLen(1))
|
|
Expect(cap.Consts[0].Type).To(Equal("ScrobblerErrorType"))
|
|
Expect(cap.Consts[0].Values).To(HaveLen(2))
|
|
Expect(cap.Consts[0].Values[0].Name).To(Equal("ScrobblerErrorNone"))
|
|
Expect(cap.Consts[0].Values[0].Value).To(Equal(`"none"`))
|
|
})
|
|
|
|
It("should collect nested struct dependencies", func() {
|
|
src := `package capabilities
|
|
|
|
//nd:capability name=metadata
|
|
type MetadataAgent interface {
|
|
//nd:export name=nd_get_images
|
|
GetImages(ArtistInput) (ImagesOutput, error)
|
|
}
|
|
|
|
type ArtistInput struct {
|
|
ID string ` + "`json:\"id\"`" + `
|
|
}
|
|
|
|
type ImagesOutput struct {
|
|
Images []ImageInfo ` + "`json:\"images\"`" + `
|
|
}
|
|
|
|
type ImageInfo struct {
|
|
URL string ` + "`json:\"url\"`" + `
|
|
Size int32 ` + "`json:\"size\"`" + `
|
|
}
|
|
`
|
|
err := os.WriteFile(filepath.Join(tmpDir, "metadata.go"), []byte(src), 0600)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
capabilities, err := ParseCapabilities(tmpDir)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(capabilities).To(HaveLen(1))
|
|
|
|
cap := capabilities[0]
|
|
// Should collect all 3 structs: ArtistInput, ImagesOutput, and ImageInfo
|
|
Expect(cap.Structs).To(HaveLen(3))
|
|
|
|
structNames := make([]string, len(cap.Structs))
|
|
for i, s := range cap.Structs {
|
|
structNames[i] = s.Name
|
|
}
|
|
Expect(structNames).To(ContainElements("ArtistInput", "ImagesOutput", "ImageInfo"))
|
|
})
|
|
|
|
It("should return empty slice for directory with no capabilities", func() {
|
|
src := `package capabilities
|
|
|
|
type RegularInterface interface {
|
|
Method() error
|
|
}
|
|
`
|
|
err := os.WriteFile(filepath.Join(tmpDir, "test.go"), []byte(src), 0600)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
capabilities, err := ParseCapabilities(tmpDir)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(capabilities).To(BeEmpty())
|
|
})
|
|
|
|
It("should ignore methods without export annotation", func() {
|
|
src := `package capabilities
|
|
|
|
//nd:capability name=test
|
|
type TestCapability interface {
|
|
//nd:export name=nd_exported
|
|
ExportedMethod(Input) (Output, error)
|
|
|
|
// This method has no export annotation
|
|
NotExportedMethod(Input) (Output, error)
|
|
}
|
|
|
|
type Input struct {
|
|
Value string ` + "`json:\"value\"`" + `
|
|
}
|
|
|
|
type Output struct {
|
|
Result string ` + "`json:\"result\"`" + `
|
|
}
|
|
`
|
|
err := os.WriteFile(filepath.Join(tmpDir, "test.go"), []byte(src), 0600)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
capabilities, err := ParseCapabilities(tmpDir)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(capabilities).To(HaveLen(1))
|
|
|
|
// Only the exported method should be captured
|
|
Expect(capabilities[0].Methods).To(HaveLen(1))
|
|
Expect(capabilities[0].Methods[0].Name).To(Equal("ExportedMethod"))
|
|
})
|
|
|
|
It("distinguishes Go type aliases from defined types", func() {
|
|
src := `package capabilities
|
|
|
|
import "github.com/navidrome/navidrome/plugins/types"
|
|
|
|
// Deprecated: use types.ArtistRef.
|
|
type ArtistRef = types.ArtistRef
|
|
|
|
// ScrobblerError is a sentinel error string.
|
|
type ScrobblerError string
|
|
|
|
//nd:capability name=scrobbler required=true
|
|
type Scrobbler interface {
|
|
//nd:export name=nd_scrobbler_check
|
|
Check(ArtistRef) (bool, error)
|
|
}
|
|
`
|
|
Expect(os.WriteFile(filepath.Join(tmpDir, "scrobbler.go"), []byte(src), 0600)).To(Succeed())
|
|
|
|
shared := map[string]StructDef{
|
|
"ArtistRef": {Name: "ArtistRef", Fields: []FieldDef{{Name: "Name", Type: "string", JSONTag: "name"}}},
|
|
}
|
|
caps, err := ParseCapabilitiesWithShared(tmpDir, shared)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(caps).To(HaveLen(1))
|
|
|
|
// ArtistRef is a shared-type alias (types.*): it lands in SharedAliases, not TypeAliases.
|
|
sharedByName := map[string]SharedAlias{}
|
|
for _, a := range caps[0].SharedAliases {
|
|
sharedByName[a.Name] = a
|
|
}
|
|
Expect(sharedByName).To(HaveKey("ArtistRef"))
|
|
Expect(sharedByName["ArtistRef"].Target).To(Equal("types.ArtistRef"))
|
|
|
|
// ScrobblerError is a plain defined type: it stays in TypeAliases.
|
|
typeByName := map[string]TypeAlias{}
|
|
for _, a := range caps[0].TypeAliases {
|
|
typeByName[a.Name] = a
|
|
}
|
|
Expect(typeByName).To(HaveKey("ScrobblerError"))
|
|
Expect(typeByName["ScrobblerError"].IsAlias).To(BeFalse())
|
|
})
|
|
})
|
|
|
|
Describe("ParseCapabilitiesWithShared", func() {
|
|
It("returns an error when a shared-type alias cannot be resolved (no registry)", func() {
|
|
src := `package capabilities
|
|
|
|
import "github.com/navidrome/navidrome/plugins/types"
|
|
|
|
// TrackInfo is an alias for the shared type.
|
|
type TrackInfo = types.TrackInfo
|
|
|
|
//nd:capability name=nowplaying required=true
|
|
type NowPlaying interface {
|
|
//nd:export name=nd_now_playing
|
|
NowPlaying(TrackInfo) error
|
|
}
|
|
`
|
|
Expect(os.WriteFile(filepath.Join(tmpDir, "nowplaying.go"), []byte(src), 0600)).To(Succeed())
|
|
|
|
_, err := ParseCapabilitiesWithShared(tmpDir, nil)
|
|
Expect(err).To(HaveOccurred())
|
|
Expect(err.Error()).To(ContainSubstring("TrackInfo"))
|
|
Expect(err.Error()).To(ContainSubstring("-shared"))
|
|
})
|
|
|
|
It("resolves shared-type aliases against the registry", func() {
|
|
shared := map[string]StructDef{
|
|
"ArtistRef": {Name: "ArtistRef", Fields: []FieldDef{{Name: "Name", Type: "string", JSONTag: "name"}}},
|
|
"TrackInfo": {Name: "TrackInfo", Fields: []FieldDef{
|
|
{Name: "Title", Type: "string", JSONTag: "title"},
|
|
{Name: "Artists", Type: "[]ArtistRef", JSONTag: "artists"},
|
|
}},
|
|
}
|
|
src := `package capabilities
|
|
|
|
import "github.com/navidrome/navidrome/plugins/types"
|
|
|
|
// Deprecated: use types.TrackInfo.
|
|
type TrackInfo = types.TrackInfo
|
|
|
|
// Deprecated: use types.ArtistRef.
|
|
type ArtistRef = types.ArtistRef
|
|
|
|
// NowPlayingRequest carries a track.
|
|
type NowPlayingRequest struct {
|
|
Track TrackInfo ` + "`json:\"track\"`" + `
|
|
}
|
|
|
|
//nd:capability name=scrobbler required=true
|
|
type Scrobbler interface {
|
|
//nd:export name=nd_scrobbler_now_playing
|
|
NowPlaying(NowPlayingRequest) error
|
|
}
|
|
`
|
|
Expect(os.WriteFile(filepath.Join(tmpDir, "scrobbler.go"), []byte(src), 0600)).To(Succeed())
|
|
|
|
caps, err := ParseCapabilitiesWithShared(tmpDir, shared)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(caps).To(HaveLen(1))
|
|
|
|
names := []string{}
|
|
for _, a := range caps[0].SharedAliases {
|
|
names = append(names, a.Name)
|
|
}
|
|
// TrackInfo is referenced directly; ArtistRef is pulled in transitively via TrackInfo.Artists.
|
|
Expect(names).To(ContainElements("TrackInfo", "ArtistRef"))
|
|
|
|
byName := map[string]SharedAlias{}
|
|
for _, a := range caps[0].SharedAliases {
|
|
byName[a.Name] = a
|
|
}
|
|
Expect(byName["TrackInfo"].Target).To(Equal("types.TrackInfo"))
|
|
Expect(byName["TrackInfo"].Def.Fields).To(HaveLen(2)) // for schema inlining
|
|
Expect(byName["ArtistRef"].Target).To(Equal("types.ArtistRef"))
|
|
})
|
|
|
|
It("resolves shared types from qualified types.X references with a renamed alias", func() {
|
|
shared := map[string]StructDef{
|
|
"ArtistRef": {Name: "ArtistRef", Fields: []FieldDef{{Name: "Name", Type: "string", JSONTag: "name"}}},
|
|
"Track": {Name: "Track", Fields: []FieldDef{
|
|
{Name: "Title", Type: "string", JSONTag: "title"},
|
|
{Name: "Artists", Type: "[]ArtistRef", JSONTag: "artists"},
|
|
}},
|
|
}
|
|
src := `package capabilities
|
|
|
|
import "github.com/navidrome/navidrome/plugins/types"
|
|
|
|
// Deprecated: use types.Track.
|
|
type TrackInfo = types.Track
|
|
|
|
// Deprecated: use types.ArtistRef.
|
|
type ArtistRef = types.ArtistRef
|
|
|
|
// NowPlayingRequest carries a track.
|
|
type NowPlayingRequest struct {
|
|
Track types.Track ` + "`json:\"track\"`" + `
|
|
}
|
|
|
|
//nd:capability name=scrobbler required=true
|
|
type Scrobbler interface {
|
|
//nd:export name=nd_scrobbler_now_playing
|
|
NowPlaying(NowPlayingRequest) error
|
|
}
|
|
`
|
|
Expect(os.WriteFile(filepath.Join(tmpDir, "scrobbler.go"), []byte(src), 0600)).To(Succeed())
|
|
|
|
caps, err := ParseCapabilitiesWithShared(tmpDir, shared)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(caps).To(HaveLen(1))
|
|
|
|
byName := map[string]SharedAlias{}
|
|
for _, a := range caps[0].SharedAliases {
|
|
byName[a.Name] = a
|
|
}
|
|
// The deprecated alias keeps its name (TrackInfo) but now targets types.Track.
|
|
// ArtistRef is pulled in transitively via Track.Artists.
|
|
Expect(byName).To(HaveKey("TrackInfo"))
|
|
Expect(byName).To(HaveKey("ArtistRef"))
|
|
Expect(byName["TrackInfo"].Target).To(Equal("types.Track"))
|
|
Expect(byName["TrackInfo"].Def.Fields).To(HaveLen(2)) // for schema inlining
|
|
Expect(byName["ArtistRef"].Target).To(Equal("types.ArtistRef"))
|
|
|
|
// The capability struct field keeps the canonical qualified reference.
|
|
var nowPlaying StructDef
|
|
for _, st := range caps[0].Structs {
|
|
if st.Name == "NowPlayingRequest" {
|
|
nowPlaying = st
|
|
}
|
|
}
|
|
Expect(nowPlaying.Fields).To(HaveLen(1))
|
|
Expect(nowPlaying.Fields[0].Type).To(Equal("types.Track"))
|
|
})
|
|
})
|
|
|
|
Describe("Export helpers", func() {
|
|
It("should generate correct provider interface name", func() {
|
|
e := Export{Name: "GetArtistBiography"}
|
|
Expect(e.ProviderInterfaceName()).To(Equal("ArtistBiographyProvider"))
|
|
|
|
e = Export{Name: "OnInit"}
|
|
Expect(e.ProviderInterfaceName()).To(Equal("InitProvider"))
|
|
})
|
|
|
|
It("should generate correct impl variable name", func() {
|
|
e := Export{Name: "GetArtistBiography"}
|
|
Expect(e.ImplVarName()).To(Equal("artistBiographyImpl"))
|
|
|
|
e = Export{Name: "OnInit"}
|
|
Expect(e.ImplVarName()).To(Equal("initImpl"))
|
|
})
|
|
|
|
It("should generate correct export function name", func() {
|
|
e := Export{Name: "GetArtistBiography", ExportName: "nd_get_artist_biography"}
|
|
Expect(e.ExportFuncName()).To(Equal("_NdGetArtistBiography"))
|
|
})
|
|
})
|
|
})
|