Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import 'package:dio/dio.dart';
/// # Catalyst Gateway API.
/// The Catalyst Gateway API provides realtime data for all prior, current and future Catalyst Voices voting events.
///
/// Based on OpenAPI Catalyst Gateway API version 0.7.0
/// catalyst-openapi/v0.7.0 - https://github.com/input-output-hk/catalyst-voices/releases/tag/catalyst-openapi%2Fv0.7.0
/// Based on OpenAPI Catalyst Gateway API version 0.8.0
/// catalyst-openapi/v0.8.0 - https://github.com/input-output-hk/catalyst-voices/releases/tag/catalyst-openapi%2Fv0.8.0
abstract interface class CatGatewayService {
factory CatGatewayService.dio({
required String baseUrl,
Expand All @@ -36,7 +36,7 @@ abstract interface class CatGatewayService {

void close();

/// Post A Signed Document Index Query for Newer Versions of v0.0.4.
/// Post A Signed Document Index Query (v2).
/// Produces a summary of signed documents that meet the criteria
/// defined in the request body for new signed document versions of v0.0.4.
///
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import 'package:catalyst_voices_repositories/src/api/models/document_reference.dart';
import 'package:json_annotation/json_annotation.dart';

part 'document_chain.g.dart';

/// A reference to the previous signed document in a sequence.
@JsonSerializable()
final class DocumentChain {
/// A document height
/// A consecutive sequence number of the current document in the chain.
final int height;

/// Document Reference for filtered Documents.
/// A reference to a single signed document.
@JsonKey(name: 'document_ref')
final DocumentReference? documentRef;

const DocumentChain({required this.height, this.documentRef});

factory DocumentChain.fromJson(Map<String, dynamic> json) => _$DocumentChainFromJson(json);

Map<String, dynamic> toJson() => _$DocumentChainToJson(this);
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:catalyst_voices_repositories/src/api/models/eq_or_ranged_id.dart';
import 'package:catalyst_voices_repositories/src/api/models/eq_or_ranged_ver.dart';
import 'package:catalyst_voices_repositories/src/api/models/id_and_ver_ref.dart';
import 'package:catalyst_voices_repositories/src/api/models/id_selector.dart';
import 'package:catalyst_voices_repositories/src/api/models/ver_selector.dart';
import 'package:json_annotation/json_annotation.dart';

part 'document_index_query_filter.g.dart';
Expand All @@ -24,21 +24,15 @@ final class DocumentIndexQueryFilter {
/// Max items 10
final List<String>? type;

/// ## Document ID
/// Document ID Selector
///
/// Either an absolute single Document ID or a range of
/// [Document IDs](https://input-output-hk.github.io/catalyst-libs/architecture/08_concepts/signed_doc/spec/#id)
///
/// Max items 10
final List<EqOrRangedId>? id;
/// Either a absolute single Document ID or a range of Document IDs
final IdSelector? id;

/// ## Document Version
/// Document Version Selector
///
/// Either an absolute single Document Version or a range of
/// [Document Versions](https://input-output-hk.github.io/catalyst-libs/architecture/08_concepts/signed_doc/spec/#ver)
///
/// Max items 10
final List<EqOrRangedVer>? ver;
/// Either a absolute single Document Version or a range of Document Versions
final VerSelector? ver;

/// ## Document Reference
///
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import 'package:json_annotation/json_annotation.dart';

part 'id_selector.g.dart';

/// Either a Single Document ID, or a Range of Document IDs
@JsonSerializable(createFactory: false, includeIfNull: false)
final class IdSelector {
/// Signed Document ID
/// The exact Document ID to match against.
final String? eq;

/// Signed Document ID
/// Minimum Document ID to find (inclusive)
final String? min;

/// Signed Document ID
/// Maximum Document ID to find (inclusive)
final String? max;

/// Signed Document ID
/// Document IDs from the list.
@JsonKey(name: 'in')
final List<String>? inside;

/// A specific single
/// [Document ID](https://input-output-hk.github.io/catalyst-libs/architecture/08_concepts/signed_doc/spec/#id).
const IdSelector.eq(String this.eq) : min = null, max = null, inside = null;

/// Document IDs from the list.
/// A list of
/// [Document IDs](https://input-output-hk.github.io/catalyst-libs/architecture/08_concepts/signed_doc/spec/#id).
const IdSelector.inside(List<String> this.inside) : eq = null, min = null, max = null;

/// A range of
/// [Document IDs](https://input-output-hk.github.io/catalyst-libs/architecture/08_concepts/signed_doc/spec/#id).
const IdSelector.range({
required String this.min,
required String this.max,
}) : eq = null,
inside = null;

Map<String, dynamic> toJson() => _$IdSelectorToJson(this);
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:catalyst_voices_repositories/src/api/models/document_chain.dart';
import 'package:catalyst_voices_repositories/src/api/models/document_reference.dart';
import 'package:json_annotation/json_annotation.dart';

Expand All @@ -14,6 +15,10 @@ final class IndexedDocumentVersion {
/// Document Type that matches the filter
final String type;

/// Signed Document ID
/// A unique document identifier that matches the filter.
final String id;

/// Document Reference that matches the filter
/// Max items 10
final List<DocumentReference>? ref;
Expand All @@ -31,13 +36,25 @@ final class IndexedDocumentVersion {
@JsonKey(name: 'doc_parameters')
final List<DocumentReference>? parameters;

/// A list of collaborators who can participate in drafting and submitting a document
/// that matches the filter.
/// Catalyst identifier in string format
final List<String>? collaborators;

/// A reference to the previous signed document in a sequence.
/// A link to a previous document in a chained sequence that matches the filter.
final DocumentChain? chain;

IndexedDocumentVersion({
required this.ver,
required this.type,
required this.id,
this.ref,
this.reply,
this.template,
this.parameters,
this.collaborators,
this.chain,
});

factory IndexedDocumentVersion.fromJson(Map<String, dynamic> json) =>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import 'package:json_annotation/json_annotation.dart';

part 'ver_selector.g.dart';

/// Document or Range of Documents
///
/// Either a Single Document Version, or a Range of Document Versions
@JsonSerializable(createFactory: false, includeIfNull: false)
final class VerSelector {
/// Signed Document Version
/// The exact Document ID to match against.
final String? eq;

/// Signed Document Version
/// Minimum Document Version to find (inclusive)
final String? min;

/// Signed Document Version
/// Maximum Document Version to find (inclusive)
final String? max;

/// Signed Document Version
/// Document versions from the list.
@JsonKey(name: 'in')
final List<String>? inside;

/// Version Equals
/// A specific single
/// [Document Version](https://input-output-hk.github.io/catalyst-libs/architecture/08_concepts/signed_doc/spec/#ver).
const VerSelector.eq(String this.eq) : min = null, max = null, inside = null;

/// Document versions from the list.
/// A list of
/// [Document IDs](https://input-output-hk.github.io/catalyst-libs/architecture/08_concepts/signed_doc/spec/#id).
const VerSelector.inside(List<String> this.inside) : eq = null, min = null, max = null;

/// Version Range
///
/// A range of
/// [Document Version](https://input-output-hk.github.io/catalyst-libs/architecture/08_concepts/signed_doc/spec/#ver).
const VerSelector.range({
required String this.min,
required String this.max,
}) : eq = null,
inside = null;

Map<String, dynamic> toJson() => _$VerSelectorToJson(this);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:catalyst_voices_repositories/src/api/models/document_index_query
import 'package:catalyst_voices_repositories/src/api/models/document_reference.dart';
import 'package:catalyst_voices_repositories/src/api/models/eq_or_ranged_id.dart';
import 'package:catalyst_voices_repositories/src/api/models/id_and_ver_ref.dart';
import 'package:catalyst_voices_repositories/src/api/models/id_selector.dart';
import 'package:catalyst_voices_repositories/src/common/future_response_mapper.dart';
import 'package:catalyst_voices_repositories/src/document/document_data_factory.dart';
import 'package:collection/collection.dart';
Expand Down Expand Up @@ -49,7 +50,7 @@ final class CatGatewayDocumentDataSource implements DocumentDataRemoteSource {
try {
final index = await _api.gateway
.documentIndex(
filter: DocumentIndexQueryFilter(id: [EqOrRangedId.eq(id)]),
filter: DocumentIndexQueryFilter(id: IdSelector.eq(id)),
limit: 1,
)
.successBodyOrThrow();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ void main() {
return IndexedDocumentVersion(
ver: e.version!,
type: DocumentType.proposalDocument.uuid,
id: '01944e87-e68c-7f22-9df1-816863cfa5ff',
template: [
DocumentReference(
id: templateRef.id,
Expand Down Expand Up @@ -155,6 +156,7 @@ IndexedDocument _buildDocumentIndexList({
return IndexedDocumentVersion(
ver: DocumentRefFactory.randomUuidV7(),
type: DocumentRefFactory.randomUuidV7(),
id: DocumentRefFactory.randomUuidV7(),
template: template,
ref: ref,
);
Expand Down