modelgate (1.4.1)
Published 2026-10-14 20:10:41 +00:00 by warkanum
Installation
dart pub add modelgate:1.4.1 --hosted-url=https://git.warky.dev/api/packages/wdevs/pub/About this package
Client for PostAPI (JSON body) and FunctionAPI endpoints.
modelgate (Dart)
Dart / Flutter client for PostAPI (JSON body) and FunctionAPI. Depends on package:http. Dart >= 3.3.
Clients
| Type | Constructor | Methods |
|---|---|---|
PostAPIClient |
(baseUrl, [ClientOptions]) |
getMetadata read create update delete close |
FunctionAPIClient |
(baseUrl, [ClientOptions]) |
query queryList close |
ClientOptions(token:, headers:, timeout:, httpClient:). Precedence: Content-Type < custom headers < bearer token.
PostAPI
id:int/String→ URL,List<String>→ body. Named args:id:,options:.Options,FilterOption(column, operator, [value, logic]),SortOption(column, [direction]).- Result:
Response{success, data (decoded JSON), metadata}.
FunctionAPI
- Routes are server-defined: pass the
path. params:map → query string (list → repeated keys, null skipped).FunctionAPIOptions→X-*headers:filters,searchFilters,customSqlWhere,customSqlOr,sort,limit,offset,distinct,skipCount,skipCache,responseFormat.queryListfillsmetadatafromContent-Range; 206 is success.- Helpers:
buildHeaders,buildQuery,encodeHeaderValue,decodeHeaderValue.
Server quirks
sortis raw SQL in ORDER BY (client sendscol ASC|DESC).- One search operator per column.
- Values starting
ZIP_/__are base64-decoded by the server. - Non-ASCII, control chars and edge spaces are auto-encoded (
ZIP_).
Errors
ModelGateException{statusCode, message, error: ApiError{code, detail, sql}}.
Test
dart test