builder_helpers library

Build-time helpers re-exposed for other generators that compose with gisila's annotations (notably gisila_doc).

Most application authors do not need to import this file; package:gisila/gisila.dart covers everything needed at runtime and package:gisila/builder.dart exposes the build_runner entry point.

Functions

dartString(String value) → String
Quotes value as a Dart single-quoted string literal.
emitGuardsRouteConfigLiteral({required bool requireAuth, required Set<String> permissions, required Set<String> anyPermission, required Set<String> roles, required bool isPublic}) → String
Synthesises a RouteConfig literal that carries auth / permission guards collected from @RequireAuth / @Permissions / @AnyPermission / @Roles / @Public annotations.
emitNamedMiddlewareConfig(Iterable<String> names) → String?
Renders a list of class-and-method @UseMiddleware names into a RouteConfig literal that places them in middleware: as app.namedMiddleware(...) lookups.
emitRouteConfigLiteral(DartObject? obj) → String
Emits a Dart source literal that reconstructs the const RouteConfig represented by obj. Returns 'RouteConfig.empty' if obj is null.
fromFormConstructor(ClassElement cls) → ConstructorElement?
Returns the fromForm(Map<String, dynamic>) factory if cls exposes one. Used to decode form-urlencoded / multipart request bodies, with priority over fromJsonConstructor when both exist.
fromJsonConstructor(ClassElement cls) → ConstructorElement?
isCoercible(DartType type) → bool
Standard primitives we can parse from a path / query / header string.
isFormData(DartType type) → bool
True iff type is FormData from package:gisila.
isFormSubtype(DartType type) → bool
True iff type is (a subclass of) the gisila Form class.
isGisilaLibrary(LibraryElement library) → bool
True for a library of package:gisila itself. Annotations are matched by where they are declared, not by name: a Public or Roles class from any other package (even one named like gisila_extras) is not ours.
isNullable(DartType type) → bool
True iff type is T? (or Null).
isRequestContext(DartType type) → bool
True iff type is RequestContext from package:gisila.
isServiceSubtype(DartType type) → bool
True iff type is (a subclass of) the gisila Service class.
isShelfRequest(DartType type) → bool
isShelfResponse(DartType type) → bool
isStringMap(DartType type) → bool
isUploadedFile(DartType type) → bool
True iff type is UploadedFile from package:gisila.
isVoid(DartType type) → bool
joinPath(String prefix, String suffix) → String
Joins a controller prefix with a method-level path, collapsing trailing/leading slashes.
listElementType(DartType type) → DartType?
pathPlaceholders(String path) → Iterable<String>
stringSetLiteral(Iterable<String> values) → String
Renders a Dart <String>{...} literal (or <String>{} for empty).
toShelfPath(String path) → String
Converts an OpenAPI-style path like /users/{id} to the shelf_router-style path /users/<id>.
typeDisplayName(DartType type) → String
Display string with the nullability suffix stripped.
typeDisplayNameNullable(DartType type) → String
Display string with explicit nullability suffix preserved.
unwrapFuture(DartType type) → DartType