Repository navigation
v1.35.0
API/server layer clean-up (behavior-preserving):
APIServerWorker: both branches of_processAPIResponseend in one
_finishResponse; helpers renamed to what they do (_buildShelfResponse,
_disposeAndCompressResponse,_startServersAndInitializeAPIRoot,
_errorResponse). TheCORSheaders are set once (they were set again
when building the headers).- Request payload: one
_readPayloadBytesfor text and binary payloads, one
maxPayloadLengthcheck, done before copying the blocks (a single
Uint8Listblock is still used as is). APIServer.toAPIRequest: headers and query parameters flattened by one
helper. New constants:APIServer.sessionIDCookieName(SESSIONID),
headerServerTiming,headerKeepAlive,headerContentLength,
headerXAPIServerWorker;APIRoot.apiInfoRoute(API-INFO) and
APIRoot.defaultAuthenticationRoute(authenticate).APISecurity: oneresolveMappedchain resolving a token's credential;
thedisposeAuthentication*methods share one helper.APIRoot: the default-module fallback shared byacceptsRequestand the
call.APIServerResponseCache: an evicted entry is removed once (not per
alternative); oneGETcheck incacheResponse.APICronScheduler._executesplit (_runCalls,_storeRunResult).FieldsFromMap: one lookup helper for the lower-case and simple keys.- Private cache fields named
*Cache, documented, declared before their
users.
Conditions and SQL generation clean-up (behavior-preserving, the same SQL):
Condition: the ordering comparisons (>,>=,<,<=) written once
(a private enum and a private base of theKeyCondition{GreaterThan,...}
classes; public API unchanged);KeyCondition.encodeValuein the base
class;ConditionParameter.matchesInresolves its parameters once.EncodingContext.parameterValue;isReservedWordby a set;
ConditionSQLEncoder.qualifiedColumnSQLand shared ID/empty-set helpers.SQLDialect.qualifiedColumnSQL;SQLGenerator.uniqueConstraintName,
indexName,foreignKeyNameandrelationshipTableName(the names of
the generated indexes, constraints and relationship tables, in one place).DBSQLAdapter: the table check (_checkDBTableScheme), the relationship
SQL generators and theJOINs split into documented helpers.DBSQLMemoryAdapter: one select matcher; shared delete helpers.APIDBModule.select: directives, table and pagination helpers.- Cache fields named
*Cacheand documented.
Entity model clean-up (behavior-preserving, except the fixes below):
- Entity rules:
EntityResolutionRules.merge/fetchTypesand
EntityAccessRules(group flattening, condition check, reversed scan)
through shared helpers. EntityHandler: one scalar equality chain forequalsValuesand
equalsValuesBasic; the comparisons through one numeric helper; a shared
cached field-type lookup forGenericEntityHandlerand
ClassReflectionEntityHandler; private caches named*Cacheand
documented.Transaction: identity sets beside the operation lists, for O(1)
membership checks (a bulkstoreAllwas O(n²)), created once a list
passes 16 operations (a smaller transaction scans its list, cheaper than
allocating the sets). Memoryremovein the benchmark: 4.9× faster.- Cascade delete,
storeAllFromJson(named block-size constants), the seed
JSON helpers, the provider lookups,IterableEntityRepositoryand
TransactionOperation.toString: duplicated blocks moved into helpers. EntityReference/EntityReferenceList,TypeInfoandMapgetter
extensions,Time,EntityPagination: duplicated code merged.isEqualsIterableDeep/intersectsIterableDeep: iterate instead of
elementAt(i)(O(n²) on a non-ListIterable).
Adapters clean-up (behavior-preserving):
DBObjectAdapter: the implementation copy-pasted in the memory,
directory and GCS object adapters (table schemes, transactions,
order/pagination, ID/table names and entity JSON normalization, operation
execution), with the hookscreateAdapterException(each adapter keeps
its exception type),encodeBytesAsDataURLandadapterLogger.DBSQLAdapter: the schema introspection of the PostgreSQL, MySQL and
SQLite adapters (tables names and fields references caches, relationship
tables) overlistTablesNamesImpl/findFieldsReferencedTablesImpl; the
30 s fields references cache TTL named;openTransactionWithPool, the
shared transaction defaults andautoInsertAfterNoopUpdate.DBEntityRepository: oneensureStoredimplementation (hooks
storeWithParentOperation,onEnsureStoredExisting) and
newSelectOperation;getEntityRepositoriesTables(the typo
getEntityRepositoresTableskept,@Deprecated).- Cache fields named
*Cacheand documented. - New API (for subclasses of the adapters):
DBSQLAdapter:@protectedopenTransactionWithPool,
listTablesNamesImpl,findFieldsReferencedTablesImpl(default: throw
UnsupportedError, for an adapter that doesn't introspect a database),
listTablesNamesCached,findFieldsReferencedTablesCached,
findRelationshipTables,autoInsertAfterNoopUpdate; the static
sqlStringLiteral.DBSQLAdapterdefaults for what was abstract:cancelTransaction
(true),closeTransaction(nothing),callCloseTransactionRequired
(false),cancelTransactionResultWithError(false),
throwTransactionResultWithError(true), the behavior of a pooled
driver whose transaction callback commits or rolls back (as the
PostgreSQL, MySQL and SQLite adapters): a subclass that relied on them
being abstract now inherits these.DBObjectAdapter:@protectedexecuteOperation,
normalizeEntityJSON,normalizeObjectID,normalizeTableName,
getTableIDFieldName,applyTableOrderAndPagination,
createAdapterException,encodeBytesAsDataURL,adapterLogger,
onTransactionContextCanceled,onTransactionContextClosed.- The object adapters'
openTransactionstays typed as their context
(synchronous);cancelTransactionof the MySQL/SQLite adapters stays
bool.
DBSQLMemoryAdapterkeeps its own relationship-tables resolution (it
doesn't introspect a database).
Deprecated (still working):
EntityHandler.graterThanValue/graterThanOrEqualValue: use
greaterThanValue/greaterThanOrEqualValue.EntityRulesResolver.cotextProviders: usecontextProviders.FieldsFromMap.getFieldsKeysInMap'sfieldLC/fieldSimple(ignored).DBAdapter.getEntityRepositoresTables: use
getEntityRepositoriesTables.
Fixes:
APIServerResponseCache: the eviction (maxMemorySizereached) sorted
the cached values, which hold aListfor an entry with compressed
alternatives: aTypeError. The entries are now sorted with all their
alternatives (by total usage and memory size).APIServerResponseCache: the eviction removed the most used entries
first (usage sorted descending): now the least used first, and among
equally used, the largest first.APIServerResponseCache: an expired entry (file modified) was removed
without subtracting its memory size fromtotalMemorySize.APIServerConfig: the user directory (Let's Encrypt paths) fell back to
Directory('~/'), a literal~directory, not the home: it's resolved
from the environment only (resolveUserDirectory):USERPROFILEthen
HOMEon Windows,HOMEthenUSERPROFILEelsewhere (other platforms,
e.g. Android, used to have none).APIServerConfig.normalizeHeaderValue: thek3path key was ignored (a
value at a 4-key config path returned the default): now used.APIServer: the JSON-decode error log printed the stack trace in place
of the invalid payload (a shadowedcatchvariable).IdenticalSet: grouped elements byhashCode, missing an element whose
hashCodechanged: now byidentityHashCode.FieldsFromMap.getFieldsKeysInMap: the givenfieldLC/fieldSimple
(of one field) were used for every field: now computed per field (the
parameters are ignored and@Deprecated).Condition.parse: an escaped quote in a single-quoted string
(name == 'a\'b') failed to parse.SQLDialect.toString: lists all its fields (and a missing space).APIDBModule.select: the entities' values are HTML-escaped in its page
(they were written as is: a<or&broke the page, and could inject
markup).GenericEntityHandler.getFieldTypewithresolveFiledName: the entity is
asked for the resolved field name (it was asked for the key again).EntityRepositoryProvider.populateFromSource:workingPathis used to
resolve the source (and the variables) file.EntityRepositoryProvider.storeAllFromJson/storeAllFromJsonEncoded:
transactionis used, and the%name%variablesare resolved (they
were ignored).EntityReference.from/EntityReferenceList.from:entityHandlerProvider
is forwarded.IterableEntityRepository.deleteEntity:transactionis forwarded.EntityAccessRules==/hashCode:entityFieldscompared element-wise
(it was identity).EntityResolutionRuleswithallEagerandallLazybothtrue: invalid
(validatethrowsValidateEntityRulesError);
isEagerEntityType/isLazyEntityTyperecursed forever on it. Amerge
of one side'sallEagerwith the other'sallLazydrops the conflict as
a same-flag one: both sides tolerant, both flags dropped; one tolerant, it
yields its flag; neither, it throws.DBPostgreSQLAdapter.doCountSQL: a result without a row threw a
StateError: now0, as the SQLite and MySQL adapters.DBPostgreSQLAdapter: the ID sequence fix after an update's auto-insert
usedmax(id), failing for a table whose ID column isn'tid: now the
table's (quoted) ID column.DBPostgreSQLAdapter,DBMySQLAdapter: the schema introspection
queries interpolated the table (and database) names into SQL string
literals unescaped: a'in a name broke (or changed) the query. Now
escaped byDBSQLAdapter.sqlStringLiteral: the'doubled, and for
MySQL (DBMySQLAdapter.mysqlStringLiteral; its defaultsql_modemakes
\an escape in literals) also the\. The queries are otherwise the
same (MySQL's foreign keys query lost two trailing spaces).