Noir::EncoreExtractor
Encore (https://encore.dev) API declarations.
Go: a //encore:api [public|private|auth] [raw] [method=A,B] [path=/p]
directive in the doc comment of a function or service method.
TypeScript: export const name = api({...}, handler) and its
api.raw / api.streamIn / api.streamOut / api.streamInOut /
api.static variants, from encore.dev/api.
Constants
FIELD_HEAD = /\A(?:readonly\s+)?["']?([A-Za-z_$][\w$-]*)["']?\??\s*:\s*/
GO_DIRECTIVE = "//encore:api"
IDENTIFIER = /\A[A-Za-z_$][\w$]*\z/
JS_RULES = TopLevelSplit::Rules::JS
TS_API = /\bexport\s+const\s+([A-Za-z_$][\w$]*)(?:\s*:[^=;\n]+)?\s*=\s*api(?:\.(raw|streamIn|streamOut|streamInOut|static))?\s*(?<generic><(?:=>|[^<>]|(?&generic))*>)?\s*\(/
The generic group recurses for nested <...> and steps over =>.
TS_IMPORT = /\bimport\s+(?:type\s+)?\{([^}]*)\}\s*from\s*["'](\.{1,2}\/[^"']+)["']/
TS_TYPE = /\b(?:interface\s+([A-Za-z_$][\w$]*)\b[^{;]*|type\s+([A-Za-z_$][\w$]*)\s*=\s*)\{/
TYPE_RULES = TopLevelSplit::Rules.new(nest: ((TopLevelSplit::Nest::Paren | TopLevelSplit::Nest::Bracket) | TopLevelSplit::Nest::Brace) | TopLevelSplit::Nest::Angle, quotes: "\"'`", empties: TopLevelSplit::Empties::DropAll, per_kind: true)
Instance methods
Fields of the interface/type named name declared in content.
Top-level generic arguments: Header<number, "X-Count"> → ["number", "\"X-Count\""].
Encore path syntax: :name and *rest params, plus the !rest
fallback, reported as *rest. Returns the URL and its param names.