Skip to content

Commit

Permalink
feat: add TempService (#1238)
Browse files Browse the repository at this point in the history
  • Loading branch information
myConsciousness committed Feb 18, 2024
1 parent e982f51 commit 6bdb1fb
Show file tree
Hide file tree
Showing 24 changed files with 737 additions and 4 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"Roboto",
"Shinya",
"shinyakato",
"Signup",
"sublist",
"Threadgate",
"tlds",
Expand Down
9 changes: 9 additions & 0 deletions packages/atproto/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Release Note

## v0.11.5

- Added `TempService`. You can use it like `atproto.temp`. ([#1238](https://github.com/myConsciousness/atproto.dart/issues/1238))
- `.checkSignupQueue`
- `.importRepo`
- `.pushBlob`
- `.requestPhoneVerification`
- `.transferAccount`

## v0.11.4

- Improved redundant error messages. Now it shows like `GET https://bsky.social/xrpc/com.atproto.identity.resolveHandle 400 Error: Params must have the property "handle"`. ([#1253](https://github.com/myConsciousness/atproto.dart/issues/1253))
Expand Down
3 changes: 3 additions & 0 deletions packages/atproto/lib/atproto.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,16 @@ export 'package:atproto/src/services/entities/subscribed_repo_migrate.dart';
export 'package:atproto/src/services/entities/subscribed_repo_tombstone.dart';
export 'package:atproto/src/services/entities/update_action.dart';
export 'package:atproto/src/services/entities/signing_key.dart';
export 'package:atproto/src/services/entities/signup_queue.dart';
export 'package:atproto/src/services/entities/transferred_account.dart';
export 'package:atproto/src/services/identity_service.dart';
export 'package:atproto/src/services/constants/moderation_reason_type.dart';
export 'package:atproto/src/services/moderation_service.dart';
export 'package:atproto/src/services/repo_service.dart';
export 'package:atproto/src/services/server_service.dart';
export 'package:atproto/src/services/sync_service.dart';
export 'package:atproto/src/services/label_service.dart';
export 'package:atproto/src/services/temp_service.dart';
export 'package:atproto_core/atproto_core.dart'
show
XRPCResponse,
Expand Down
9 changes: 9 additions & 0 deletions packages/atproto/lib/src/atproto.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import 'services/moderation_service.dart';
import 'services/repo_service.dart';
import 'services/server_service.dart';
import 'services/sync_service.dart';
import 'services/temp_service.dart';

/// Provides `com.atproto.*` services.
sealed class ATProto {
Expand Down Expand Up @@ -119,6 +120,10 @@ sealed class ATProto {
/// This service represents `com.atproto.label.*`.
LabelService get label;

/// Returns the temp service.
/// This service represents `com.atproto.temp.*`.
TempService get temp;

/// Returns the result of executing [methodId] as GET communication.
///
/// You can specify `Map<String, dynamic>`, `Uint8List`, or `EmptyData` as
Expand Down Expand Up @@ -169,6 +174,7 @@ final class _ATProto implements ATProto {
moderation = ModerationService(ctx),
sync = SyncService(ctx),
label = LabelService(ctx),
temp = TempService(ctx),
_ctx = ctx;

@override
Expand Down Expand Up @@ -210,6 +216,9 @@ final class _ATProto implements ATProto {
@override
LabelService get labels => label;

@override
final TempService temp;

final core.ServiceContext _ctx;

@override
Expand Down
26 changes: 26 additions & 0 deletions packages/atproto/lib/src/services/entities/signup_queue.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright 2023 Shinya Kato. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided the conditions.

// 📦 Package imports:
import 'package:freezed_annotation/freezed_annotation.dart';

// 🌎 Project imports:
import '../../lex_annotations.g.dart' as lex;

part 'signup_queue.freezed.dart';
part 'signup_queue.g.dart';

/// https://atprotodart.com/docs/lexicons/com/atproto/temp/checkSignupQueue/#output
@freezed
@lex.comAtprotoTempCheckSignupQueue
class SignupQueue with _$SignupQueue {
const factory SignupQueue({
required bool activated,
int? placeInQueue,
int? estimatedTimeMs,
}) = _SignupQueue;

factory SignupQueue.fromJson(Map<String, Object?> json) =>
_$SignupQueueFromJson(json);
}
191 changes: 191 additions & 0 deletions packages/atproto/lib/src/services/entities/signup_queue.freezed.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark

part of 'signup_queue.dart';

// **************************************************************************
// FreezedGenerator
// **************************************************************************

T _$identity<T>(T value) => value;

final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods');

SignupQueue _$SignupQueueFromJson(Map<String, dynamic> json) {
return _SignupQueue.fromJson(json);
}

/// @nodoc
mixin _$SignupQueue {
bool get activated => throw _privateConstructorUsedError;
int? get placeInQueue => throw _privateConstructorUsedError;
int? get estimatedTimeMs => throw _privateConstructorUsedError;

Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$SignupQueueCopyWith<SignupQueue> get copyWith =>
throw _privateConstructorUsedError;
}

/// @nodoc
abstract class $SignupQueueCopyWith<$Res> {
factory $SignupQueueCopyWith(
SignupQueue value, $Res Function(SignupQueue) then) =
_$SignupQueueCopyWithImpl<$Res, SignupQueue>;
@useResult
$Res call({bool activated, int? placeInQueue, int? estimatedTimeMs});
}

/// @nodoc
class _$SignupQueueCopyWithImpl<$Res, $Val extends SignupQueue>
implements $SignupQueueCopyWith<$Res> {
_$SignupQueueCopyWithImpl(this._value, this._then);

// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;

@pragma('vm:prefer-inline')
@override
$Res call({
Object? activated = null,
Object? placeInQueue = freezed,
Object? estimatedTimeMs = freezed,
}) {
return _then(_value.copyWith(
activated: null == activated
? _value.activated
: activated // ignore: cast_nullable_to_non_nullable
as bool,
placeInQueue: freezed == placeInQueue
? _value.placeInQueue
: placeInQueue // ignore: cast_nullable_to_non_nullable
as int?,
estimatedTimeMs: freezed == estimatedTimeMs
? _value.estimatedTimeMs
: estimatedTimeMs // ignore: cast_nullable_to_non_nullable
as int?,
) as $Val);
}
}

/// @nodoc
abstract class _$$SignupQueueImplCopyWith<$Res>
implements $SignupQueueCopyWith<$Res> {
factory _$$SignupQueueImplCopyWith(
_$SignupQueueImpl value, $Res Function(_$SignupQueueImpl) then) =
__$$SignupQueueImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({bool activated, int? placeInQueue, int? estimatedTimeMs});
}

/// @nodoc
class __$$SignupQueueImplCopyWithImpl<$Res>
extends _$SignupQueueCopyWithImpl<$Res, _$SignupQueueImpl>
implements _$$SignupQueueImplCopyWith<$Res> {
__$$SignupQueueImplCopyWithImpl(
_$SignupQueueImpl _value, $Res Function(_$SignupQueueImpl) _then)
: super(_value, _then);

@pragma('vm:prefer-inline')
@override
$Res call({
Object? activated = null,
Object? placeInQueue = freezed,
Object? estimatedTimeMs = freezed,
}) {
return _then(_$SignupQueueImpl(
activated: null == activated
? _value.activated
: activated // ignore: cast_nullable_to_non_nullable
as bool,
placeInQueue: freezed == placeInQueue
? _value.placeInQueue
: placeInQueue // ignore: cast_nullable_to_non_nullable
as int?,
estimatedTimeMs: freezed == estimatedTimeMs
? _value.estimatedTimeMs
: estimatedTimeMs // ignore: cast_nullable_to_non_nullable
as int?,
));
}
}

/// @nodoc
@JsonSerializable()
class _$SignupQueueImpl implements _SignupQueue {
const _$SignupQueueImpl(
{required this.activated, this.placeInQueue, this.estimatedTimeMs});

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

@override
final bool activated;
@override
final int? placeInQueue;
@override
final int? estimatedTimeMs;

@override
String toString() {
return 'SignupQueue(activated: $activated, placeInQueue: $placeInQueue, estimatedTimeMs: $estimatedTimeMs)';
}

@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$SignupQueueImpl &&
(identical(other.activated, activated) ||
other.activated == activated) &&
(identical(other.placeInQueue, placeInQueue) ||
other.placeInQueue == placeInQueue) &&
(identical(other.estimatedTimeMs, estimatedTimeMs) ||
other.estimatedTimeMs == estimatedTimeMs));
}

@JsonKey(ignore: true)
@override
int get hashCode =>
Object.hash(runtimeType, activated, placeInQueue, estimatedTimeMs);

@JsonKey(ignore: true)
@override
@pragma('vm:prefer-inline')
_$$SignupQueueImplCopyWith<_$SignupQueueImpl> get copyWith =>
__$$SignupQueueImplCopyWithImpl<_$SignupQueueImpl>(this, _$identity);

@override
Map<String, dynamic> toJson() {
return _$$SignupQueueImplToJson(
this,
);
}
}

abstract class _SignupQueue implements SignupQueue {
const factory _SignupQueue(
{required final bool activated,
final int? placeInQueue,
final int? estimatedTimeMs}) = _$SignupQueueImpl;

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

@override
bool get activated;
@override
int? get placeInQueue;
@override
int? get estimatedTimeMs;
@override
@JsonKey(ignore: true)
_$$SignupQueueImplCopyWith<_$SignupQueueImpl> get copyWith =>
throw _privateConstructorUsedError;
}
29 changes: 29 additions & 0 deletions packages/atproto/lib/src/services/entities/signup_queue.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright 2024 Shinya Kato. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided the conditions.

// 📦 Package imports:
import 'package:atproto_core/atproto_core.dart';
import 'package:freezed_annotation/freezed_annotation.dart';

part 'transferred_account.freezed.dart';
part 'transferred_account.g.dart';

@freezed
class TransferredAccount with _$TransferredAccount {
// ignore: unused_element
const TransferredAccount._();

@jsonSerializable
const factory TransferredAccount({
required String did,
required String handle,
required String accessJwt,
required String refreshJwt,
}) = _TransferredAccount;

factory TransferredAccount.fromJson(Map<String, Object?> json) =>
_$TransferredAccountFromJson(json);

/// Returns decoded [accessJwt].
AuthToken get accessToken => decodeJwt(accessJwt);

Check warning on line 29 in packages/atproto/lib/src/services/entities/transferred_account.dart

View check run for this annotation

Codecov / codecov/patch

packages/atproto/lib/src/services/entities/transferred_account.dart#L29

Added line #L29 was not covered by tests

/// Returns decoded [refreshJwt].
AuthToken get refreshToken => decodeJwt(refreshJwt);

Check warning on line 32 in packages/atproto/lib/src/services/entities/transferred_account.dart

View check run for this annotation

Codecov / codecov/patch

packages/atproto/lib/src/services/entities/transferred_account.dart#L32

Added line #L32 was not covered by tests
}
Loading

0 comments on commit 6bdb1fb

Please sign in to comment.