diff --git a/.gitignore b/.gitignore index 31e840c..a2b2a17 100644 --- a/.gitignore +++ b/.gitignore @@ -93,3 +93,6 @@ keystore.properties # Local build secrets (Giphy etc.) — injected via --dart-define-from-file dart_defines.json + +# drift generated code is committed so CI needs no build_runner step (#335) +!/lib/storage/drift/offband_database.g.dart diff --git a/lib/storage/drift/offband_database.g.dart b/lib/storage/drift/offband_database.g.dart new file mode 100644 index 0000000..38c23ac --- /dev/null +++ b/lib/storage/drift/offband_database.g.dart @@ -0,0 +1,445 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'offband_database.dart'; + +// ignore_for_file: type=lint +class $StoredBlobsTable extends StoredBlobs + with TableInfo<$StoredBlobsTable, StoredBlob> { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + $StoredBlobsTable(this.attachedDatabase, [this._alias]); + static const VerificationMeta _keyMeta = const VerificationMeta('key'); + @override + late final GeneratedColumn key = GeneratedColumn( + 'key', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + ); + static const VerificationMeta _valueMeta = const VerificationMeta('value'); + @override + late final GeneratedColumn value = GeneratedColumn( + 'value', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + ); + static const VerificationMeta _updatedAtMeta = const VerificationMeta( + 'updatedAt', + ); + @override + late final GeneratedColumn updatedAt = GeneratedColumn( + 'updated_at', + aliasedName, + false, + type: DriftSqlType.dateTime, + requiredDuringInsert: false, + defaultValue: currentDateAndTime, + ); + @override + List get $columns => [key, value, updatedAt]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'stored_blobs'; + @override + VerificationContext validateIntegrity( + Insertable instance, { + bool isInserting = false, + }) { + final context = VerificationContext(); + final data = instance.toColumns(true); + if (data.containsKey('key')) { + context.handle( + _keyMeta, + key.isAcceptableOrUnknown(data['key']!, _keyMeta), + ); + } else if (isInserting) { + context.missing(_keyMeta); + } + if (data.containsKey('value')) { + context.handle( + _valueMeta, + value.isAcceptableOrUnknown(data['value']!, _valueMeta), + ); + } else if (isInserting) { + context.missing(_valueMeta); + } + if (data.containsKey('updated_at')) { + context.handle( + _updatedAtMeta, + updatedAt.isAcceptableOrUnknown(data['updated_at']!, _updatedAtMeta), + ); + } + return context; + } + + @override + Set get $primaryKey => {key}; + @override + StoredBlob map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return StoredBlob( + key: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}key'], + )!, + value: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}value'], + )!, + updatedAt: attachedDatabase.typeMapping.read( + DriftSqlType.dateTime, + data['${effectivePrefix}updated_at'], + )!, + ); + } + + @override + $StoredBlobsTable createAlias(String alias) { + return $StoredBlobsTable(attachedDatabase, alias); + } +} + +class StoredBlob extends DataClass implements Insertable { + final String key; + final String value; + final DateTime updatedAt; + const StoredBlob({ + required this.key, + required this.value, + required this.updatedAt, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['key'] = Variable(key); + map['value'] = Variable(value); + map['updated_at'] = Variable(updatedAt); + return map; + } + + StoredBlobsCompanion toCompanion(bool nullToAbsent) { + return StoredBlobsCompanion( + key: Value(key), + value: Value(value), + updatedAt: Value(updatedAt), + ); + } + + factory StoredBlob.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return StoredBlob( + key: serializer.fromJson(json['key']), + value: serializer.fromJson(json['value']), + updatedAt: serializer.fromJson(json['updatedAt']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'key': serializer.toJson(key), + 'value': serializer.toJson(value), + 'updatedAt': serializer.toJson(updatedAt), + }; + } + + StoredBlob copyWith({String? key, String? value, DateTime? updatedAt}) => + StoredBlob( + key: key ?? this.key, + value: value ?? this.value, + updatedAt: updatedAt ?? this.updatedAt, + ); + StoredBlob copyWithCompanion(StoredBlobsCompanion data) { + return StoredBlob( + key: data.key.present ? data.key.value : this.key, + value: data.value.present ? data.value.value : this.value, + updatedAt: data.updatedAt.present ? data.updatedAt.value : this.updatedAt, + ); + } + + @override + String toString() { + return (StringBuffer('StoredBlob(') + ..write('key: $key, ') + ..write('value: $value, ') + ..write('updatedAt: $updatedAt') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash(key, value, updatedAt); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is StoredBlob && + other.key == this.key && + other.value == this.value && + other.updatedAt == this.updatedAt); +} + +class StoredBlobsCompanion extends UpdateCompanion { + final Value key; + final Value value; + final Value updatedAt; + final Value rowid; + const StoredBlobsCompanion({ + this.key = const Value.absent(), + this.value = const Value.absent(), + this.updatedAt = const Value.absent(), + this.rowid = const Value.absent(), + }); + StoredBlobsCompanion.insert({ + required String key, + required String value, + this.updatedAt = const Value.absent(), + this.rowid = const Value.absent(), + }) : key = Value(key), + value = Value(value); + static Insertable custom({ + Expression? key, + Expression? value, + Expression? updatedAt, + Expression? rowid, + }) { + return RawValuesInsertable({ + if (key != null) 'key': key, + if (value != null) 'value': value, + if (updatedAt != null) 'updated_at': updatedAt, + if (rowid != null) 'rowid': rowid, + }); + } + + StoredBlobsCompanion copyWith({ + Value? key, + Value? value, + Value? updatedAt, + Value? rowid, + }) { + return StoredBlobsCompanion( + key: key ?? this.key, + value: value ?? this.value, + updatedAt: updatedAt ?? this.updatedAt, + rowid: rowid ?? this.rowid, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (key.present) { + map['key'] = Variable(key.value); + } + if (value.present) { + map['value'] = Variable(value.value); + } + if (updatedAt.present) { + map['updated_at'] = Variable(updatedAt.value); + } + if (rowid.present) { + map['rowid'] = Variable(rowid.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('StoredBlobsCompanion(') + ..write('key: $key, ') + ..write('value: $value, ') + ..write('updatedAt: $updatedAt, ') + ..write('rowid: $rowid') + ..write(')')) + .toString(); + } +} + +abstract class _$OffbandDatabase extends GeneratedDatabase { + _$OffbandDatabase(QueryExecutor e) : super(e); + $OffbandDatabaseManager get managers => $OffbandDatabaseManager(this); + late final $StoredBlobsTable storedBlobs = $StoredBlobsTable(this); + @override + Iterable> get allTables => + allSchemaEntities.whereType>(); + @override + List get allSchemaEntities => [storedBlobs]; +} + +typedef $$StoredBlobsTableCreateCompanionBuilder = + StoredBlobsCompanion Function({ + required String key, + required String value, + Value updatedAt, + Value rowid, + }); +typedef $$StoredBlobsTableUpdateCompanionBuilder = + StoredBlobsCompanion Function({ + Value key, + Value value, + Value updatedAt, + Value rowid, + }); + +class $$StoredBlobsTableFilterComposer + extends Composer<_$OffbandDatabase, $StoredBlobsTable> { + $$StoredBlobsTableFilterComposer({ + required super.$db, + required super.$table, + super.joinBuilder, + super.$addJoinBuilderToRootComposer, + super.$removeJoinBuilderFromRootComposer, + }); + ColumnFilters get key => $composableBuilder( + column: $table.key, + builder: (column) => ColumnFilters(column), + ); + + ColumnFilters get value => $composableBuilder( + column: $table.value, + builder: (column) => ColumnFilters(column), + ); + + ColumnFilters get updatedAt => $composableBuilder( + column: $table.updatedAt, + builder: (column) => ColumnFilters(column), + ); +} + +class $$StoredBlobsTableOrderingComposer + extends Composer<_$OffbandDatabase, $StoredBlobsTable> { + $$StoredBlobsTableOrderingComposer({ + required super.$db, + required super.$table, + super.joinBuilder, + super.$addJoinBuilderToRootComposer, + super.$removeJoinBuilderFromRootComposer, + }); + ColumnOrderings get key => $composableBuilder( + column: $table.key, + builder: (column) => ColumnOrderings(column), + ); + + ColumnOrderings get value => $composableBuilder( + column: $table.value, + builder: (column) => ColumnOrderings(column), + ); + + ColumnOrderings get updatedAt => $composableBuilder( + column: $table.updatedAt, + builder: (column) => ColumnOrderings(column), + ); +} + +class $$StoredBlobsTableAnnotationComposer + extends Composer<_$OffbandDatabase, $StoredBlobsTable> { + $$StoredBlobsTableAnnotationComposer({ + required super.$db, + required super.$table, + super.joinBuilder, + super.$addJoinBuilderToRootComposer, + super.$removeJoinBuilderFromRootComposer, + }); + GeneratedColumn get key => + $composableBuilder(column: $table.key, builder: (column) => column); + + GeneratedColumn get value => + $composableBuilder(column: $table.value, builder: (column) => column); + + GeneratedColumn get updatedAt => + $composableBuilder(column: $table.updatedAt, builder: (column) => column); +} + +class $$StoredBlobsTableTableManager + extends + RootTableManager< + _$OffbandDatabase, + $StoredBlobsTable, + StoredBlob, + $$StoredBlobsTableFilterComposer, + $$StoredBlobsTableOrderingComposer, + $$StoredBlobsTableAnnotationComposer, + $$StoredBlobsTableCreateCompanionBuilder, + $$StoredBlobsTableUpdateCompanionBuilder, + ( + StoredBlob, + BaseReferences<_$OffbandDatabase, $StoredBlobsTable, StoredBlob>, + ), + StoredBlob, + PrefetchHooks Function() + > { + $$StoredBlobsTableTableManager(_$OffbandDatabase db, $StoredBlobsTable table) + : super( + TableManagerState( + db: db, + table: table, + createFilteringComposer: () => + $$StoredBlobsTableFilterComposer($db: db, $table: table), + createOrderingComposer: () => + $$StoredBlobsTableOrderingComposer($db: db, $table: table), + createComputedFieldComposer: () => + $$StoredBlobsTableAnnotationComposer($db: db, $table: table), + updateCompanionCallback: + ({ + Value key = const Value.absent(), + Value value = const Value.absent(), + Value updatedAt = const Value.absent(), + Value rowid = const Value.absent(), + }) => StoredBlobsCompanion( + key: key, + value: value, + updatedAt: updatedAt, + rowid: rowid, + ), + createCompanionCallback: + ({ + required String key, + required String value, + Value updatedAt = const Value.absent(), + Value rowid = const Value.absent(), + }) => StoredBlobsCompanion.insert( + key: key, + value: value, + updatedAt: updatedAt, + rowid: rowid, + ), + withReferenceMapper: (p0) => p0 + .map((e) => (e.readTable(table), BaseReferences(db, table, e))) + .toList(), + prefetchHooksCallback: null, + ), + ); +} + +typedef $$StoredBlobsTableProcessedTableManager = + ProcessedTableManager< + _$OffbandDatabase, + $StoredBlobsTable, + StoredBlob, + $$StoredBlobsTableFilterComposer, + $$StoredBlobsTableOrderingComposer, + $$StoredBlobsTableAnnotationComposer, + $$StoredBlobsTableCreateCompanionBuilder, + $$StoredBlobsTableUpdateCompanionBuilder, + ( + StoredBlob, + BaseReferences<_$OffbandDatabase, $StoredBlobsTable, StoredBlob>, + ), + StoredBlob, + PrefetchHooks Function() + >; + +class $OffbandDatabaseManager { + final _$OffbandDatabase _db; + $OffbandDatabaseManager(this._db); + $$StoredBlobsTableTableManager get storedBlobs => + $$StoredBlobsTableTableManager(_db, _db.storedBlobs); +} diff --git a/pubspec.yaml b/pubspec.yaml index d385dd6..3a9ab39 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -102,7 +102,7 @@ dev_dependencies: # rules and activating additional ones. flutter_lints: ^6.0.0 flutter_launcher_icons: ^0.14.4 - drift_dev: ^2.34.0 + drift_dev: 2.34.0 build_runner: ^2.15.1 # For information on the generic Dart part of this file, see the