From f581c1561cefa7dbd05bff64ff25fcd5a232556a Mon Sep 17 00:00:00 2001 From: Remi Rousselet Date: Thu, 1 Aug 2024 14:53:36 +0200 Subject: [PATCH 1/7] Add schema --- .../globe_cli/lib/src/graphql/admin.graphql | 17 + .../lib/src/graphql/admin.graphql.dart | 48 + .../globe_cli/lib/src/graphql/billing.graphql | 94 ++ .../lib/src/graphql/billing.graphql.dart | 427 ++++++ .../lib/src/graphql/deployment.graphql | 43 + .../lib/src/graphql/deployment.graphql.dart | 184 +++ packages/globe_cli/lib/src/graphql/me.graphql | 38 + .../globe_cli/lib/src/graphql/me.graphql.dart | 1 + .../lib/src/graphql/organization.graphql | 32 + .../lib/src/graphql/organization.graphql.dart | 33 + .../globe_cli/lib/src/graphql/project.graphql | 93 ++ .../lib/src/graphql/project.graphql.dart | 1147 +++++++++++++++++ .../globe_cli/lib/src/graphql/scalars.graphql | 1 + .../lib/src/graphql/scalars.graphql.dart | 1 + .../globe_cli/lib/src/graphql/schema.graphql | 16 + .../lib/src/graphql/schema.graphql.dart | 247 ++++ .../lib/src/graphql/statistics.graphql | 34 + .../lib/src/graphql/statistics.graphql.dart | 37 + .../globe_cli/lib/src/graphql/token.graphql | 43 + .../lib/src/graphql/token.graphql.dart | 1 + 20 files changed, 2537 insertions(+) create mode 100644 packages/globe_cli/lib/src/graphql/admin.graphql create mode 100644 packages/globe_cli/lib/src/graphql/admin.graphql.dart create mode 100644 packages/globe_cli/lib/src/graphql/billing.graphql create mode 100644 packages/globe_cli/lib/src/graphql/billing.graphql.dart create mode 100644 packages/globe_cli/lib/src/graphql/deployment.graphql create mode 100644 packages/globe_cli/lib/src/graphql/deployment.graphql.dart create mode 100644 packages/globe_cli/lib/src/graphql/me.graphql create mode 100644 packages/globe_cli/lib/src/graphql/me.graphql.dart create mode 100644 packages/globe_cli/lib/src/graphql/organization.graphql create mode 100644 packages/globe_cli/lib/src/graphql/organization.graphql.dart create mode 100644 packages/globe_cli/lib/src/graphql/project.graphql create mode 100644 packages/globe_cli/lib/src/graphql/project.graphql.dart create mode 100644 packages/globe_cli/lib/src/graphql/scalars.graphql create mode 100644 packages/globe_cli/lib/src/graphql/scalars.graphql.dart create mode 100644 packages/globe_cli/lib/src/graphql/schema.graphql create mode 100644 packages/globe_cli/lib/src/graphql/schema.graphql.dart create mode 100644 packages/globe_cli/lib/src/graphql/statistics.graphql create mode 100644 packages/globe_cli/lib/src/graphql/statistics.graphql.dart create mode 100644 packages/globe_cli/lib/src/graphql/token.graphql create mode 100644 packages/globe_cli/lib/src/graphql/token.graphql.dart diff --git a/packages/globe_cli/lib/src/graphql/admin.graphql b/packages/globe_cli/lib/src/graphql/admin.graphql new file mode 100644 index 0000000..e719de4 --- /dev/null +++ b/packages/globe_cli/lib/src/graphql/admin.graphql @@ -0,0 +1,17 @@ +union Entity = Project | Organization | Deployment | GlobeUser + +enum EntityType { + Organization + Deployment + Project + UserId + BuildId +} + +type Admin { + searchId(type: EntityType!, id: String!): Entity @isAdmin +} + +extend type Query { + admin: Admin @isAdmin +} diff --git a/packages/globe_cli/lib/src/graphql/admin.graphql.dart b/packages/globe_cli/lib/src/graphql/admin.graphql.dart new file mode 100644 index 0000000..df8ac36 --- /dev/null +++ b/packages/globe_cli/lib/src/graphql/admin.graphql.dart @@ -0,0 +1,48 @@ +// ignore_for_file: type=lint +enum Enum$EntityType { + Organization, + Deployment, + Project, + UserId, + BuildId, + $unknown; + + factory Enum$EntityType.fromJson(String value) => + fromJson$Enum$EntityType(value); + + String toJson() => toJson$Enum$EntityType(this); +} + +String toJson$Enum$EntityType(Enum$EntityType e) { + switch (e) { + case Enum$EntityType.Organization: + return r'Organization'; + case Enum$EntityType.Deployment: + return r'Deployment'; + case Enum$EntityType.Project: + return r'Project'; + case Enum$EntityType.UserId: + return r'UserId'; + case Enum$EntityType.BuildId: + return r'BuildId'; + case Enum$EntityType.$unknown: + return r'$unknown'; + } +} + +Enum$EntityType fromJson$Enum$EntityType(String value) { + switch (value) { + case r'Organization': + return Enum$EntityType.Organization; + case r'Deployment': + return Enum$EntityType.Deployment; + case r'Project': + return Enum$EntityType.Project; + case r'UserId': + return Enum$EntityType.UserId; + case r'BuildId': + return Enum$EntityType.BuildId; + default: + return Enum$EntityType.$unknown; + } +} diff --git a/packages/globe_cli/lib/src/graphql/billing.graphql b/packages/globe_cli/lib/src/graphql/billing.graphql new file mode 100644 index 0000000..53a8bb2 --- /dev/null +++ b/packages/globe_cli/lib/src/graphql/billing.graphql @@ -0,0 +1,94 @@ +enum BillingProductTypeEnum { + subscription +} + +enum BillingProductDataDurationEnum { + once + day + week + month + year +} + +enum BillingProductUsageTypeEnum { + request + bandwidth +} + +type BillingProduct { + id: ID! + name: String! + """ + Admin Only + """ + providerId: String! @isAdmin + type: BillingProductTypeEnum! + isActive: Boolean! + items: [BillingProductItem!]! +} + +type BillingProductItem { + id: ID! + """ + Admin Only + """ + providerId: String! @isAdmin + name: String! + data: BillingProductItemData! + isActive: Boolean! +} + +input BillingProductItemInput { + providerId: String! + name: String! + usages: [BillingProductItemUsageInput!]! +} + +type BillingProductItemUsage { + usageType: BillingProductUsageTypeEnum! + usageLimit: Int! +} + +input BillingProductItemUsageInput { + usageType: BillingProductUsageTypeEnum! + usageLimit: Int! +} + +type BillingProductItemData { + price: Float! + currency: String! + description: String + duration: BillingProductDataDurationEnum +} + +extend type Query { + billingProducts(type: BillingProductTypeEnum!): [BillingProduct!]! +} + +extend type Mutation { + createBillingProduct( + name: String! + providerId: String! + type: BillingProductTypeEnum! + items: [BillingProductItemInput!]! + ): SuccessResponse! @isAdmin + updateBillingProduct( + id: ID! + name: String + providerId: String + type: BillingProductTypeEnum + ): SuccessResponse! @isAdmin + deleteBillingProduct(id: ID!): SuccessResponse! @isAdmin + updateBillingProductItem( + id: ID! + name: String + providerId: String + ): SuccessResponse! @isAdmin + deleteBillingProductItem(id: ID!): SuccessResponse! @isAdmin + updateBillingProductItemUsage( + id: Int! + usageType: BillingProductUsageTypeEnum + usageLimit: Int + ): SuccessResponse! @isAdmin + deleteBillingProductItemUsage(id: Int!): SuccessResponse! @isAdmin +} diff --git a/packages/globe_cli/lib/src/graphql/billing.graphql.dart b/packages/globe_cli/lib/src/graphql/billing.graphql.dart new file mode 100644 index 0000000..adc6957 --- /dev/null +++ b/packages/globe_cli/lib/src/graphql/billing.graphql.dart @@ -0,0 +1,427 @@ +// ignore_for_file: type=lint +class Input$BillingProductItemInput { + factory Input$BillingProductItemInput({ + required String providerId, + required String name, + required List usages, + }) => + Input$BillingProductItemInput._({ + r'providerId': providerId, + r'name': name, + r'usages': usages, + }); + + Input$BillingProductItemInput._(this._$data); + + factory Input$BillingProductItemInput.fromJson(Map data) { + final result$data = {}; + final l$providerId = data['providerId']; + result$data['providerId'] = (l$providerId as String); + final l$name = data['name']; + result$data['name'] = (l$name as String); + final l$usages = data['usages']; + result$data['usages'] = (l$usages as List) + .map((e) => Input$BillingProductItemUsageInput.fromJson( + (e as Map))) + .toList(); + return Input$BillingProductItemInput._(result$data); + } + + Map _$data; + + String get providerId => (_$data['providerId'] as String); + + String get name => (_$data['name'] as String); + + List get usages => + (_$data['usages'] as List); + + Map toJson() { + final result$data = {}; + final l$providerId = providerId; + result$data['providerId'] = l$providerId; + final l$name = name; + result$data['name'] = l$name; + final l$usages = usages; + result$data['usages'] = l$usages.map((e) => e.toJson()).toList(); + return result$data; + } + + CopyWith$Input$BillingProductItemInput + get copyWith => CopyWith$Input$BillingProductItemInput( + this, + (i) => i, + ); + + @override + bool operator ==(Object other) { + if (identical(this, other)) { + return true; + } + if (!(other is Input$BillingProductItemInput) || + runtimeType != other.runtimeType) { + return false; + } + final l$providerId = providerId; + final lOther$providerId = other.providerId; + if (l$providerId != lOther$providerId) { + return false; + } + final l$name = name; + final lOther$name = other.name; + if (l$name != lOther$name) { + return false; + } + final l$usages = usages; + final lOther$usages = other.usages; + if (l$usages.length != lOther$usages.length) { + return false; + } + for (int i = 0; i < l$usages.length; i++) { + final l$usages$entry = l$usages[i]; + final lOther$usages$entry = lOther$usages[i]; + if (l$usages$entry != lOther$usages$entry) { + return false; + } + } + return true; + } + + @override + int get hashCode { + final l$providerId = providerId; + final l$name = name; + final l$usages = usages; + return Object.hashAll([ + l$providerId, + l$name, + Object.hashAll(l$usages.map((v) => v)), + ]); + } +} + +abstract class CopyWith$Input$BillingProductItemInput { + factory CopyWith$Input$BillingProductItemInput( + Input$BillingProductItemInput instance, + TRes Function(Input$BillingProductItemInput) then, + ) = _CopyWithImpl$Input$BillingProductItemInput; + + factory CopyWith$Input$BillingProductItemInput.stub(TRes res) = + _CopyWithStubImpl$Input$BillingProductItemInput; + + TRes call({ + String? providerId, + String? name, + List? usages, + }); + TRes usages( + Iterable Function( + Iterable< + CopyWith$Input$BillingProductItemUsageInput< + Input$BillingProductItemUsageInput>>) + _fn); +} + +class _CopyWithImpl$Input$BillingProductItemInput + implements CopyWith$Input$BillingProductItemInput { + _CopyWithImpl$Input$BillingProductItemInput( + this._instance, + this._then, + ); + + final Input$BillingProductItemInput _instance; + + final TRes Function(Input$BillingProductItemInput) _then; + + static const _undefined = {}; + + TRes call({ + Object? providerId = _undefined, + Object? name = _undefined, + Object? usages = _undefined, + }) => + _then(Input$BillingProductItemInput._({ + ..._instance._$data, + if (providerId != _undefined && providerId != null) + 'providerId': (providerId as String), + if (name != _undefined && name != null) 'name': (name as String), + if (usages != _undefined && usages != null) + 'usages': (usages as List), + })); + + TRes usages( + Iterable Function( + Iterable< + CopyWith$Input$BillingProductItemUsageInput< + Input$BillingProductItemUsageInput>>) + _fn) => + call( + usages: _fn(_instance.usages + .map((e) => CopyWith$Input$BillingProductItemUsageInput( + e, + (i) => i, + ))).toList()); +} + +class _CopyWithStubImpl$Input$BillingProductItemInput + implements CopyWith$Input$BillingProductItemInput { + _CopyWithStubImpl$Input$BillingProductItemInput(this._res); + + TRes _res; + + call({ + String? providerId, + String? name, + List? usages, + }) => + _res; + + usages(_fn) => _res; +} + +class Input$BillingProductItemUsageInput { + factory Input$BillingProductItemUsageInput({ + required Enum$BillingProductUsageTypeEnum usageType, + required int usageLimit, + }) => + Input$BillingProductItemUsageInput._({ + r'usageType': usageType, + r'usageLimit': usageLimit, + }); + + Input$BillingProductItemUsageInput._(this._$data); + + factory Input$BillingProductItemUsageInput.fromJson( + Map data) { + final result$data = {}; + final l$usageType = data['usageType']; + result$data['usageType'] = + fromJson$Enum$BillingProductUsageTypeEnum((l$usageType as String)); + final l$usageLimit = data['usageLimit']; + result$data['usageLimit'] = (l$usageLimit as int); + return Input$BillingProductItemUsageInput._(result$data); + } + + Map _$data; + + Enum$BillingProductUsageTypeEnum get usageType => + (_$data['usageType'] as Enum$BillingProductUsageTypeEnum); + + int get usageLimit => (_$data['usageLimit'] as int); + + Map toJson() { + final result$data = {}; + final l$usageType = usageType; + result$data['usageType'] = + toJson$Enum$BillingProductUsageTypeEnum(l$usageType); + final l$usageLimit = usageLimit; + result$data['usageLimit'] = l$usageLimit; + return result$data; + } + + CopyWith$Input$BillingProductItemUsageInput< + Input$BillingProductItemUsageInput> + get copyWith => CopyWith$Input$BillingProductItemUsageInput( + this, + (i) => i, + ); + + @override + bool operator ==(Object other) { + if (identical(this, other)) { + return true; + } + if (!(other is Input$BillingProductItemUsageInput) || + runtimeType != other.runtimeType) { + return false; + } + final l$usageType = usageType; + final lOther$usageType = other.usageType; + if (l$usageType != lOther$usageType) { + return false; + } + final l$usageLimit = usageLimit; + final lOther$usageLimit = other.usageLimit; + if (l$usageLimit != lOther$usageLimit) { + return false; + } + return true; + } + + @override + int get hashCode { + final l$usageType = usageType; + final l$usageLimit = usageLimit; + return Object.hashAll([ + l$usageType, + l$usageLimit, + ]); + } +} + +abstract class CopyWith$Input$BillingProductItemUsageInput { + factory CopyWith$Input$BillingProductItemUsageInput( + Input$BillingProductItemUsageInput instance, + TRes Function(Input$BillingProductItemUsageInput) then, + ) = _CopyWithImpl$Input$BillingProductItemUsageInput; + + factory CopyWith$Input$BillingProductItemUsageInput.stub(TRes res) = + _CopyWithStubImpl$Input$BillingProductItemUsageInput; + + TRes call({ + Enum$BillingProductUsageTypeEnum? usageType, + int? usageLimit, + }); +} + +class _CopyWithImpl$Input$BillingProductItemUsageInput + implements CopyWith$Input$BillingProductItemUsageInput { + _CopyWithImpl$Input$BillingProductItemUsageInput( + this._instance, + this._then, + ); + + final Input$BillingProductItemUsageInput _instance; + + final TRes Function(Input$BillingProductItemUsageInput) _then; + + static const _undefined = {}; + + TRes call({ + Object? usageType = _undefined, + Object? usageLimit = _undefined, + }) => + _then(Input$BillingProductItemUsageInput._({ + ..._instance._$data, + if (usageType != _undefined && usageType != null) + 'usageType': (usageType as Enum$BillingProductUsageTypeEnum), + if (usageLimit != _undefined && usageLimit != null) + 'usageLimit': (usageLimit as int), + })); +} + +class _CopyWithStubImpl$Input$BillingProductItemUsageInput + implements CopyWith$Input$BillingProductItemUsageInput { + _CopyWithStubImpl$Input$BillingProductItemUsageInput(this._res); + + TRes _res; + + call({ + Enum$BillingProductUsageTypeEnum? usageType, + int? usageLimit, + }) => + _res; +} + +enum Enum$BillingProductTypeEnum { + subscription, + $unknown; + + factory Enum$BillingProductTypeEnum.fromJson(String value) => + fromJson$Enum$BillingProductTypeEnum(value); + + String toJson() => toJson$Enum$BillingProductTypeEnum(this); +} + +String toJson$Enum$BillingProductTypeEnum(Enum$BillingProductTypeEnum e) { + switch (e) { + case Enum$BillingProductTypeEnum.subscription: + return r'subscription'; + case Enum$BillingProductTypeEnum.$unknown: + return r'$unknown'; + } +} + +Enum$BillingProductTypeEnum fromJson$Enum$BillingProductTypeEnum(String value) { + switch (value) { + case r'subscription': + return Enum$BillingProductTypeEnum.subscription; + default: + return Enum$BillingProductTypeEnum.$unknown; + } +} + +enum Enum$BillingProductDataDurationEnum { + once, + day, + week, + month, + year, + $unknown; + + factory Enum$BillingProductDataDurationEnum.fromJson(String value) => + fromJson$Enum$BillingProductDataDurationEnum(value); + + String toJson() => toJson$Enum$BillingProductDataDurationEnum(this); +} + +String toJson$Enum$BillingProductDataDurationEnum( + Enum$BillingProductDataDurationEnum e) { + switch (e) { + case Enum$BillingProductDataDurationEnum.once: + return r'once'; + case Enum$BillingProductDataDurationEnum.day: + return r'day'; + case Enum$BillingProductDataDurationEnum.week: + return r'week'; + case Enum$BillingProductDataDurationEnum.month: + return r'month'; + case Enum$BillingProductDataDurationEnum.year: + return r'year'; + case Enum$BillingProductDataDurationEnum.$unknown: + return r'$unknown'; + } +} + +Enum$BillingProductDataDurationEnum + fromJson$Enum$BillingProductDataDurationEnum(String value) { + switch (value) { + case r'once': + return Enum$BillingProductDataDurationEnum.once; + case r'day': + return Enum$BillingProductDataDurationEnum.day; + case r'week': + return Enum$BillingProductDataDurationEnum.week; + case r'month': + return Enum$BillingProductDataDurationEnum.month; + case r'year': + return Enum$BillingProductDataDurationEnum.year; + default: + return Enum$BillingProductDataDurationEnum.$unknown; + } +} + +enum Enum$BillingProductUsageTypeEnum { + request, + bandwidth, + $unknown; + + factory Enum$BillingProductUsageTypeEnum.fromJson(String value) => + fromJson$Enum$BillingProductUsageTypeEnum(value); + + String toJson() => toJson$Enum$BillingProductUsageTypeEnum(this); +} + +String toJson$Enum$BillingProductUsageTypeEnum( + Enum$BillingProductUsageTypeEnum e) { + switch (e) { + case Enum$BillingProductUsageTypeEnum.request: + return r'request'; + case Enum$BillingProductUsageTypeEnum.bandwidth: + return r'bandwidth'; + case Enum$BillingProductUsageTypeEnum.$unknown: + return r'$unknown'; + } +} + +Enum$BillingProductUsageTypeEnum fromJson$Enum$BillingProductUsageTypeEnum( + String value) { + switch (value) { + case r'request': + return Enum$BillingProductUsageTypeEnum.request; + case r'bandwidth': + return Enum$BillingProductUsageTypeEnum.bandwidth; + default: + return Enum$BillingProductUsageTypeEnum.$unknown; + } +} diff --git a/packages/globe_cli/lib/src/graphql/deployment.graphql b/packages/globe_cli/lib/src/graphql/deployment.graphql new file mode 100644 index 0000000..ac353f2 --- /dev/null +++ b/packages/globe_cli/lib/src/graphql/deployment.graphql @@ -0,0 +1,43 @@ +enum DeploymentStatus { + triggered + build_api_error + github_api_error + queue_api_error + deployed + pending + queued + working + success + status_unknown + failure + internal_error + timeout + cancelled + expired +} + +enum DeploymentState { + pending + working + deploying + success + error + cancelled +} + +enum DeploymentEnvironment { + production + preview +} + +type Deployment { + id: String! + uuid: String! + status: DeploymentStatus! + state: DeploymentState! + buildId: String + url: String! + environment: DeploymentEnvironment! + createdAt: DateTime! + updatedAt: DateTime! +} diff --git a/packages/globe_cli/lib/src/graphql/deployment.graphql.dart b/packages/globe_cli/lib/src/graphql/deployment.graphql.dart new file mode 100644 index 0000000..d764414 --- /dev/null +++ b/packages/globe_cli/lib/src/graphql/deployment.graphql.dart @@ -0,0 +1,184 @@ +// ignore_for_file: type=lint +enum Enum$DeploymentStatus { + triggered, + build_api_error, + github_api_error, + queue_api_error, + deployed, + pending, + queued, + working, + success, + status_unknown, + failure, + internal_error, + timeout, + cancelled, + expired, + $unknown; + + factory Enum$DeploymentStatus.fromJson(String value) => + fromJson$Enum$DeploymentStatus(value); + + String toJson() => toJson$Enum$DeploymentStatus(this); +} + +String toJson$Enum$DeploymentStatus(Enum$DeploymentStatus e) { + switch (e) { + case Enum$DeploymentStatus.triggered: + return r'triggered'; + case Enum$DeploymentStatus.build_api_error: + return r'build_api_error'; + case Enum$DeploymentStatus.github_api_error: + return r'github_api_error'; + case Enum$DeploymentStatus.queue_api_error: + return r'queue_api_error'; + case Enum$DeploymentStatus.deployed: + return r'deployed'; + case Enum$DeploymentStatus.pending: + return r'pending'; + case Enum$DeploymentStatus.queued: + return r'queued'; + case Enum$DeploymentStatus.working: + return r'working'; + case Enum$DeploymentStatus.success: + return r'success'; + case Enum$DeploymentStatus.status_unknown: + return r'status_unknown'; + case Enum$DeploymentStatus.failure: + return r'failure'; + case Enum$DeploymentStatus.internal_error: + return r'internal_error'; + case Enum$DeploymentStatus.timeout: + return r'timeout'; + case Enum$DeploymentStatus.cancelled: + return r'cancelled'; + case Enum$DeploymentStatus.expired: + return r'expired'; + case Enum$DeploymentStatus.$unknown: + return r'$unknown'; + } +} + +Enum$DeploymentStatus fromJson$Enum$DeploymentStatus(String value) { + switch (value) { + case r'triggered': + return Enum$DeploymentStatus.triggered; + case r'build_api_error': + return Enum$DeploymentStatus.build_api_error; + case r'github_api_error': + return Enum$DeploymentStatus.github_api_error; + case r'queue_api_error': + return Enum$DeploymentStatus.queue_api_error; + case r'deployed': + return Enum$DeploymentStatus.deployed; + case r'pending': + return Enum$DeploymentStatus.pending; + case r'queued': + return Enum$DeploymentStatus.queued; + case r'working': + return Enum$DeploymentStatus.working; + case r'success': + return Enum$DeploymentStatus.success; + case r'status_unknown': + return Enum$DeploymentStatus.status_unknown; + case r'failure': + return Enum$DeploymentStatus.failure; + case r'internal_error': + return Enum$DeploymentStatus.internal_error; + case r'timeout': + return Enum$DeploymentStatus.timeout; + case r'cancelled': + return Enum$DeploymentStatus.cancelled; + case r'expired': + return Enum$DeploymentStatus.expired; + default: + return Enum$DeploymentStatus.$unknown; + } +} + +enum Enum$DeploymentState { + pending, + working, + deploying, + success, + error, + cancelled, + $unknown; + + factory Enum$DeploymentState.fromJson(String value) => + fromJson$Enum$DeploymentState(value); + + String toJson() => toJson$Enum$DeploymentState(this); +} + +String toJson$Enum$DeploymentState(Enum$DeploymentState e) { + switch (e) { + case Enum$DeploymentState.pending: + return r'pending'; + case Enum$DeploymentState.working: + return r'working'; + case Enum$DeploymentState.deploying: + return r'deploying'; + case Enum$DeploymentState.success: + return r'success'; + case Enum$DeploymentState.error: + return r'error'; + case Enum$DeploymentState.cancelled: + return r'cancelled'; + case Enum$DeploymentState.$unknown: + return r'$unknown'; + } +} + +Enum$DeploymentState fromJson$Enum$DeploymentState(String value) { + switch (value) { + case r'pending': + return Enum$DeploymentState.pending; + case r'working': + return Enum$DeploymentState.working; + case r'deploying': + return Enum$DeploymentState.deploying; + case r'success': + return Enum$DeploymentState.success; + case r'error': + return Enum$DeploymentState.error; + case r'cancelled': + return Enum$DeploymentState.cancelled; + default: + return Enum$DeploymentState.$unknown; + } +} + +enum Enum$DeploymentEnvironment { + production, + preview, + $unknown; + + factory Enum$DeploymentEnvironment.fromJson(String value) => + fromJson$Enum$DeploymentEnvironment(value); + + String toJson() => toJson$Enum$DeploymentEnvironment(this); +} + +String toJson$Enum$DeploymentEnvironment(Enum$DeploymentEnvironment e) { + switch (e) { + case Enum$DeploymentEnvironment.production: + return r'production'; + case Enum$DeploymentEnvironment.preview: + return r'preview'; + case Enum$DeploymentEnvironment.$unknown: + return r'$unknown'; + } +} + +Enum$DeploymentEnvironment fromJson$Enum$DeploymentEnvironment(String value) { + switch (value) { + case r'production': + return Enum$DeploymentEnvironment.production; + case r'preview': + return Enum$DeploymentEnvironment.preview; + default: + return Enum$DeploymentEnvironment.$unknown; + } +} diff --git a/packages/globe_cli/lib/src/graphql/me.graphql b/packages/globe_cli/lib/src/graphql/me.graphql new file mode 100644 index 0000000..8d21266 --- /dev/null +++ b/packages/globe_cli/lib/src/graphql/me.graphql @@ -0,0 +1,38 @@ +interface User { + id: String! + email: String! + emailVerified: Boolean! + imageUrl: String! + name: String! + admin: Boolean! + updatedAt: DateTime! + createdAt: DateTime! +} + +type Me implements User { + id: String! + email: String! + emailVerified: Boolean! + imageUrl: String! + name: String! + admin: Boolean! + updatedAt: DateTime! + createdAt: DateTime! + organizations: [Organization!] +} + +type GlobeUser implements User { + id: String! + email: String! + emailVerified: Boolean! + imageUrl: String! + name: String! + admin: Boolean! + updatedAt: DateTime! + createdAt: DateTime! + organizations: [Organization!] +} + +extend type Query { + me: Me +} diff --git a/packages/globe_cli/lib/src/graphql/me.graphql.dart b/packages/globe_cli/lib/src/graphql/me.graphql.dart new file mode 100644 index 0000000..5f8fc03 --- /dev/null +++ b/packages/globe_cli/lib/src/graphql/me.graphql.dart @@ -0,0 +1 @@ +// ignore_for_file: type=lint diff --git a/packages/globe_cli/lib/src/graphql/organization.graphql b/packages/globe_cli/lib/src/graphql/organization.graphql new file mode 100644 index 0000000..cd1b8fb --- /dev/null +++ b/packages/globe_cli/lib/src/graphql/organization.graphql @@ -0,0 +1,32 @@ +enum OrganizationType { + personal + organization +} + +type OrganizationMember implements User { + id: String! + email: String! + emailVerified: Boolean! + imageUrl: String! + name: String! + admin: Boolean! + updatedAt: DateTime! + createdAt: DateTime! + role: String! +} + +type Organization { + id: String! + name: String! + slug: String! + imageUrl: String + type: OrganizationType! + updatedAt: DateTime! + createdAt: DateTime! + members: [OrganizationMember!] +} + +extend type Query { + organization(slug: String!): Organization + organizations: [Organization!] +} diff --git a/packages/globe_cli/lib/src/graphql/organization.graphql.dart b/packages/globe_cli/lib/src/graphql/organization.graphql.dart new file mode 100644 index 0000000..be57f2a --- /dev/null +++ b/packages/globe_cli/lib/src/graphql/organization.graphql.dart @@ -0,0 +1,33 @@ +// ignore_for_file: type=lint +enum Enum$OrganizationType { + personal, + organization, + $unknown; + + factory Enum$OrganizationType.fromJson(String value) => + fromJson$Enum$OrganizationType(value); + + String toJson() => toJson$Enum$OrganizationType(this); +} + +String toJson$Enum$OrganizationType(Enum$OrganizationType e) { + switch (e) { + case Enum$OrganizationType.personal: + return r'personal'; + case Enum$OrganizationType.organization: + return r'organization'; + case Enum$OrganizationType.$unknown: + return r'$unknown'; + } +} + +Enum$OrganizationType fromJson$Enum$OrganizationType(String value) { + switch (value) { + case r'personal': + return Enum$OrganizationType.personal; + case r'organization': + return Enum$OrganizationType.organization; + default: + return Enum$OrganizationType.$unknown; + } +} diff --git a/packages/globe_cli/lib/src/graphql/project.graphql b/packages/globe_cli/lib/src/graphql/project.graphql new file mode 100644 index 0000000..c936bfb --- /dev/null +++ b/packages/globe_cli/lib/src/graphql/project.graphql @@ -0,0 +1,93 @@ +enum FrameworkPreset { + dart_frog + flutter + serverpod +} + +enum ProjectStatus { + active + paused + marked_for_deletion + deletion_in_progress +} + +type Project { + id: String! + slug: String! + createdAt: DateTime! + updatedAt: DateTime! + status: ProjectStatus! + settings: ProjectSettings +} + +type ProjectSettings { + preset: FrameworkPreset + presetVersion: String + presetBuildCommand: String + buildImage: String + buildCommand: String + entrypoint: String + rootDirectory: String + melosDetection: Boolean + melosCommand: String + melosVersion: String + buildRunnerDetection: Boolean + buildRunnerCommand: String + preferredRegions: [String!] + flutterWebResourcesCdn: Boolean +} + +input ProjectSettingsInput { + preset: FrameworkPreset + presetVersion: String + presetBuildCommand: String + buildImage: String + buildCommand: String + entrypoint: String + rootDirectory: String + melosDetection: Boolean + melosCommand: String + melosVersion: String + buildRunnerDetection: Boolean + buildRunnerCommand: String + preferredRegions: [String!] + flutterWebResourcesCdn: Boolean +} + +input ProjectConnectionInput { + provider: String! + owner: String! + repository: String! + installationId: Int! + repositoryId: Int! + branch: String! +} + +input CreateProjectInput { + orgSlug: String! + slug: String! + settings: ProjectSettingsInput + connection: ProjectConnectionInput +} + +input UpdateProjectSlugInput { + orgSlug: String! + slug: String! +} + +extend type Query { + projects(offset: Int, limit: Int, orgSlug: String!): [Project!]! + project(orgSlug: String!, slug: String!): Project +} + +extend type Mutation { + createProject(input: CreateProjectInput!): Project! + updateProjectSlug(id: String!, input: UpdateProjectSlugInput!): SuccessResponse! + pauseProject(orgSlug: String!, projectId: String!): SuccessResponse! + resumeProject(orgSlug: String!, projectId: String!): SuccessResponse! +} + +extend type Mutation { + pauseProject(orgSlug: String!, projectId: String!): SuccessResponse! + resumeProject(orgSlug: String!, projectId: String!): SuccessResponse! +} diff --git a/packages/globe_cli/lib/src/graphql/project.graphql.dart b/packages/globe_cli/lib/src/graphql/project.graphql.dart new file mode 100644 index 0000000..9d97e34 --- /dev/null +++ b/packages/globe_cli/lib/src/graphql/project.graphql.dart @@ -0,0 +1,1147 @@ +// ignore_for_file: type=lint +class Input$ProjectSettingsInput { + factory Input$ProjectSettingsInput({ + Enum$FrameworkPreset? preset, + String? presetVersion, + String? presetBuildCommand, + String? buildImage, + String? buildCommand, + String? entrypoint, + String? rootDirectory, + bool? melosDetection, + String? melosCommand, + String? melosVersion, + bool? buildRunnerDetection, + String? buildRunnerCommand, + List? preferredRegions, + bool? flutterWebResourcesCdn, + }) => + Input$ProjectSettingsInput._({ + if (preset != null) r'preset': preset, + if (presetVersion != null) r'presetVersion': presetVersion, + if (presetBuildCommand != null) + r'presetBuildCommand': presetBuildCommand, + if (buildImage != null) r'buildImage': buildImage, + if (buildCommand != null) r'buildCommand': buildCommand, + if (entrypoint != null) r'entrypoint': entrypoint, + if (rootDirectory != null) r'rootDirectory': rootDirectory, + if (melosDetection != null) r'melosDetection': melosDetection, + if (melosCommand != null) r'melosCommand': melosCommand, + if (melosVersion != null) r'melosVersion': melosVersion, + if (buildRunnerDetection != null) + r'buildRunnerDetection': buildRunnerDetection, + if (buildRunnerCommand != null) + r'buildRunnerCommand': buildRunnerCommand, + if (preferredRegions != null) r'preferredRegions': preferredRegions, + if (flutterWebResourcesCdn != null) + r'flutterWebResourcesCdn': flutterWebResourcesCdn, + }); + + Input$ProjectSettingsInput._(this._$data); + + factory Input$ProjectSettingsInput.fromJson(Map data) { + final result$data = {}; + if (data.containsKey('preset')) { + final l$preset = data['preset']; + result$data['preset'] = l$preset == null + ? null + : fromJson$Enum$FrameworkPreset((l$preset as String)); + } + if (data.containsKey('presetVersion')) { + final l$presetVersion = data['presetVersion']; + result$data['presetVersion'] = (l$presetVersion as String?); + } + if (data.containsKey('presetBuildCommand')) { + final l$presetBuildCommand = data['presetBuildCommand']; + result$data['presetBuildCommand'] = (l$presetBuildCommand as String?); + } + if (data.containsKey('buildImage')) { + final l$buildImage = data['buildImage']; + result$data['buildImage'] = (l$buildImage as String?); + } + if (data.containsKey('buildCommand')) { + final l$buildCommand = data['buildCommand']; + result$data['buildCommand'] = (l$buildCommand as String?); + } + if (data.containsKey('entrypoint')) { + final l$entrypoint = data['entrypoint']; + result$data['entrypoint'] = (l$entrypoint as String?); + } + if (data.containsKey('rootDirectory')) { + final l$rootDirectory = data['rootDirectory']; + result$data['rootDirectory'] = (l$rootDirectory as String?); + } + if (data.containsKey('melosDetection')) { + final l$melosDetection = data['melosDetection']; + result$data['melosDetection'] = (l$melosDetection as bool?); + } + if (data.containsKey('melosCommand')) { + final l$melosCommand = data['melosCommand']; + result$data['melosCommand'] = (l$melosCommand as String?); + } + if (data.containsKey('melosVersion')) { + final l$melosVersion = data['melosVersion']; + result$data['melosVersion'] = (l$melosVersion as String?); + } + if (data.containsKey('buildRunnerDetection')) { + final l$buildRunnerDetection = data['buildRunnerDetection']; + result$data['buildRunnerDetection'] = (l$buildRunnerDetection as bool?); + } + if (data.containsKey('buildRunnerCommand')) { + final l$buildRunnerCommand = data['buildRunnerCommand']; + result$data['buildRunnerCommand'] = (l$buildRunnerCommand as String?); + } + if (data.containsKey('preferredRegions')) { + final l$preferredRegions = data['preferredRegions']; + result$data['preferredRegions'] = (l$preferredRegions as List?) + ?.map((e) => (e as String)) + .toList(); + } + if (data.containsKey('flutterWebResourcesCdn')) { + final l$flutterWebResourcesCdn = data['flutterWebResourcesCdn']; + result$data['flutterWebResourcesCdn'] = + (l$flutterWebResourcesCdn as bool?); + } + return Input$ProjectSettingsInput._(result$data); + } + + Map _$data; + + Enum$FrameworkPreset? get preset => + (_$data['preset'] as Enum$FrameworkPreset?); + + String? get presetVersion => (_$data['presetVersion'] as String?); + + String? get presetBuildCommand => (_$data['presetBuildCommand'] as String?); + + String? get buildImage => (_$data['buildImage'] as String?); + + String? get buildCommand => (_$data['buildCommand'] as String?); + + String? get entrypoint => (_$data['entrypoint'] as String?); + + String? get rootDirectory => (_$data['rootDirectory'] as String?); + + bool? get melosDetection => (_$data['melosDetection'] as bool?); + + String? get melosCommand => (_$data['melosCommand'] as String?); + + String? get melosVersion => (_$data['melosVersion'] as String?); + + bool? get buildRunnerDetection => (_$data['buildRunnerDetection'] as bool?); + + String? get buildRunnerCommand => (_$data['buildRunnerCommand'] as String?); + + List? get preferredRegions => + (_$data['preferredRegions'] as List?); + + bool? get flutterWebResourcesCdn => + (_$data['flutterWebResourcesCdn'] as bool?); + + Map toJson() { + final result$data = {}; + if (_$data.containsKey('preset')) { + final l$preset = preset; + result$data['preset'] = + l$preset == null ? null : toJson$Enum$FrameworkPreset(l$preset); + } + if (_$data.containsKey('presetVersion')) { + final l$presetVersion = presetVersion; + result$data['presetVersion'] = l$presetVersion; + } + if (_$data.containsKey('presetBuildCommand')) { + final l$presetBuildCommand = presetBuildCommand; + result$data['presetBuildCommand'] = l$presetBuildCommand; + } + if (_$data.containsKey('buildImage')) { + final l$buildImage = buildImage; + result$data['buildImage'] = l$buildImage; + } + if (_$data.containsKey('buildCommand')) { + final l$buildCommand = buildCommand; + result$data['buildCommand'] = l$buildCommand; + } + if (_$data.containsKey('entrypoint')) { + final l$entrypoint = entrypoint; + result$data['entrypoint'] = l$entrypoint; + } + if (_$data.containsKey('rootDirectory')) { + final l$rootDirectory = rootDirectory; + result$data['rootDirectory'] = l$rootDirectory; + } + if (_$data.containsKey('melosDetection')) { + final l$melosDetection = melosDetection; + result$data['melosDetection'] = l$melosDetection; + } + if (_$data.containsKey('melosCommand')) { + final l$melosCommand = melosCommand; + result$data['melosCommand'] = l$melosCommand; + } + if (_$data.containsKey('melosVersion')) { + final l$melosVersion = melosVersion; + result$data['melosVersion'] = l$melosVersion; + } + if (_$data.containsKey('buildRunnerDetection')) { + final l$buildRunnerDetection = buildRunnerDetection; + result$data['buildRunnerDetection'] = l$buildRunnerDetection; + } + if (_$data.containsKey('buildRunnerCommand')) { + final l$buildRunnerCommand = buildRunnerCommand; + result$data['buildRunnerCommand'] = l$buildRunnerCommand; + } + if (_$data.containsKey('preferredRegions')) { + final l$preferredRegions = preferredRegions; + result$data['preferredRegions'] = + l$preferredRegions?.map((e) => e).toList(); + } + if (_$data.containsKey('flutterWebResourcesCdn')) { + final l$flutterWebResourcesCdn = flutterWebResourcesCdn; + result$data['flutterWebResourcesCdn'] = l$flutterWebResourcesCdn; + } + return result$data; + } + + CopyWith$Input$ProjectSettingsInput + get copyWith => CopyWith$Input$ProjectSettingsInput( + this, + (i) => i, + ); + + @override + bool operator ==(Object other) { + if (identical(this, other)) { + return true; + } + if (!(other is Input$ProjectSettingsInput) || + runtimeType != other.runtimeType) { + return false; + } + final l$preset = preset; + final lOther$preset = other.preset; + if (_$data.containsKey('preset') != other._$data.containsKey('preset')) { + return false; + } + if (l$preset != lOther$preset) { + return false; + } + final l$presetVersion = presetVersion; + final lOther$presetVersion = other.presetVersion; + if (_$data.containsKey('presetVersion') != + other._$data.containsKey('presetVersion')) { + return false; + } + if (l$presetVersion != lOther$presetVersion) { + return false; + } + final l$presetBuildCommand = presetBuildCommand; + final lOther$presetBuildCommand = other.presetBuildCommand; + if (_$data.containsKey('presetBuildCommand') != + other._$data.containsKey('presetBuildCommand')) { + return false; + } + if (l$presetBuildCommand != lOther$presetBuildCommand) { + return false; + } + final l$buildImage = buildImage; + final lOther$buildImage = other.buildImage; + if (_$data.containsKey('buildImage') != + other._$data.containsKey('buildImage')) { + return false; + } + if (l$buildImage != lOther$buildImage) { + return false; + } + final l$buildCommand = buildCommand; + final lOther$buildCommand = other.buildCommand; + if (_$data.containsKey('buildCommand') != + other._$data.containsKey('buildCommand')) { + return false; + } + if (l$buildCommand != lOther$buildCommand) { + return false; + } + final l$entrypoint = entrypoint; + final lOther$entrypoint = other.entrypoint; + if (_$data.containsKey('entrypoint') != + other._$data.containsKey('entrypoint')) { + return false; + } + if (l$entrypoint != lOther$entrypoint) { + return false; + } + final l$rootDirectory = rootDirectory; + final lOther$rootDirectory = other.rootDirectory; + if (_$data.containsKey('rootDirectory') != + other._$data.containsKey('rootDirectory')) { + return false; + } + if (l$rootDirectory != lOther$rootDirectory) { + return false; + } + final l$melosDetection = melosDetection; + final lOther$melosDetection = other.melosDetection; + if (_$data.containsKey('melosDetection') != + other._$data.containsKey('melosDetection')) { + return false; + } + if (l$melosDetection != lOther$melosDetection) { + return false; + } + final l$melosCommand = melosCommand; + final lOther$melosCommand = other.melosCommand; + if (_$data.containsKey('melosCommand') != + other._$data.containsKey('melosCommand')) { + return false; + } + if (l$melosCommand != lOther$melosCommand) { + return false; + } + final l$melosVersion = melosVersion; + final lOther$melosVersion = other.melosVersion; + if (_$data.containsKey('melosVersion') != + other._$data.containsKey('melosVersion')) { + return false; + } + if (l$melosVersion != lOther$melosVersion) { + return false; + } + final l$buildRunnerDetection = buildRunnerDetection; + final lOther$buildRunnerDetection = other.buildRunnerDetection; + if (_$data.containsKey('buildRunnerDetection') != + other._$data.containsKey('buildRunnerDetection')) { + return false; + } + if (l$buildRunnerDetection != lOther$buildRunnerDetection) { + return false; + } + final l$buildRunnerCommand = buildRunnerCommand; + final lOther$buildRunnerCommand = other.buildRunnerCommand; + if (_$data.containsKey('buildRunnerCommand') != + other._$data.containsKey('buildRunnerCommand')) { + return false; + } + if (l$buildRunnerCommand != lOther$buildRunnerCommand) { + return false; + } + final l$preferredRegions = preferredRegions; + final lOther$preferredRegions = other.preferredRegions; + if (_$data.containsKey('preferredRegions') != + other._$data.containsKey('preferredRegions')) { + return false; + } + if (l$preferredRegions != null && lOther$preferredRegions != null) { + if (l$preferredRegions.length != lOther$preferredRegions.length) { + return false; + } + for (int i = 0; i < l$preferredRegions.length; i++) { + final l$preferredRegions$entry = l$preferredRegions[i]; + final lOther$preferredRegions$entry = lOther$preferredRegions[i]; + if (l$preferredRegions$entry != lOther$preferredRegions$entry) { + return false; + } + } + } else if (l$preferredRegions != lOther$preferredRegions) { + return false; + } + final l$flutterWebResourcesCdn = flutterWebResourcesCdn; + final lOther$flutterWebResourcesCdn = other.flutterWebResourcesCdn; + if (_$data.containsKey('flutterWebResourcesCdn') != + other._$data.containsKey('flutterWebResourcesCdn')) { + return false; + } + if (l$flutterWebResourcesCdn != lOther$flutterWebResourcesCdn) { + return false; + } + return true; + } + + @override + int get hashCode { + final l$preset = preset; + final l$presetVersion = presetVersion; + final l$presetBuildCommand = presetBuildCommand; + final l$buildImage = buildImage; + final l$buildCommand = buildCommand; + final l$entrypoint = entrypoint; + final l$rootDirectory = rootDirectory; + final l$melosDetection = melosDetection; + final l$melosCommand = melosCommand; + final l$melosVersion = melosVersion; + final l$buildRunnerDetection = buildRunnerDetection; + final l$buildRunnerCommand = buildRunnerCommand; + final l$preferredRegions = preferredRegions; + final l$flutterWebResourcesCdn = flutterWebResourcesCdn; + return Object.hashAll([ + _$data.containsKey('preset') ? l$preset : const {}, + _$data.containsKey('presetVersion') ? l$presetVersion : const {}, + _$data.containsKey('presetBuildCommand') + ? l$presetBuildCommand + : const {}, + _$data.containsKey('buildImage') ? l$buildImage : const {}, + _$data.containsKey('buildCommand') ? l$buildCommand : const {}, + _$data.containsKey('entrypoint') ? l$entrypoint : const {}, + _$data.containsKey('rootDirectory') ? l$rootDirectory : const {}, + _$data.containsKey('melosDetection') ? l$melosDetection : const {}, + _$data.containsKey('melosCommand') ? l$melosCommand : const {}, + _$data.containsKey('melosVersion') ? l$melosVersion : const {}, + _$data.containsKey('buildRunnerDetection') + ? l$buildRunnerDetection + : const {}, + _$data.containsKey('buildRunnerCommand') + ? l$buildRunnerCommand + : const {}, + _$data.containsKey('preferredRegions') + ? l$preferredRegions == null + ? null + : Object.hashAll(l$preferredRegions.map((v) => v)) + : const {}, + _$data.containsKey('flutterWebResourcesCdn') + ? l$flutterWebResourcesCdn + : const {}, + ]); + } +} + +abstract class CopyWith$Input$ProjectSettingsInput { + factory CopyWith$Input$ProjectSettingsInput( + Input$ProjectSettingsInput instance, + TRes Function(Input$ProjectSettingsInput) then, + ) = _CopyWithImpl$Input$ProjectSettingsInput; + + factory CopyWith$Input$ProjectSettingsInput.stub(TRes res) = + _CopyWithStubImpl$Input$ProjectSettingsInput; + + TRes call({ + Enum$FrameworkPreset? preset, + String? presetVersion, + String? presetBuildCommand, + String? buildImage, + String? buildCommand, + String? entrypoint, + String? rootDirectory, + bool? melosDetection, + String? melosCommand, + String? melosVersion, + bool? buildRunnerDetection, + String? buildRunnerCommand, + List? preferredRegions, + bool? flutterWebResourcesCdn, + }); +} + +class _CopyWithImpl$Input$ProjectSettingsInput + implements CopyWith$Input$ProjectSettingsInput { + _CopyWithImpl$Input$ProjectSettingsInput( + this._instance, + this._then, + ); + + final Input$ProjectSettingsInput _instance; + + final TRes Function(Input$ProjectSettingsInput) _then; + + static const _undefined = {}; + + TRes call({ + Object? preset = _undefined, + Object? presetVersion = _undefined, + Object? presetBuildCommand = _undefined, + Object? buildImage = _undefined, + Object? buildCommand = _undefined, + Object? entrypoint = _undefined, + Object? rootDirectory = _undefined, + Object? melosDetection = _undefined, + Object? melosCommand = _undefined, + Object? melosVersion = _undefined, + Object? buildRunnerDetection = _undefined, + Object? buildRunnerCommand = _undefined, + Object? preferredRegions = _undefined, + Object? flutterWebResourcesCdn = _undefined, + }) => + _then(Input$ProjectSettingsInput._({ + ..._instance._$data, + if (preset != _undefined) 'preset': (preset as Enum$FrameworkPreset?), + if (presetVersion != _undefined) + 'presetVersion': (presetVersion as String?), + if (presetBuildCommand != _undefined) + 'presetBuildCommand': (presetBuildCommand as String?), + if (buildImage != _undefined) 'buildImage': (buildImage as String?), + if (buildCommand != _undefined) + 'buildCommand': (buildCommand as String?), + if (entrypoint != _undefined) 'entrypoint': (entrypoint as String?), + if (rootDirectory != _undefined) + 'rootDirectory': (rootDirectory as String?), + if (melosDetection != _undefined) + 'melosDetection': (melosDetection as bool?), + if (melosCommand != _undefined) + 'melosCommand': (melosCommand as String?), + if (melosVersion != _undefined) + 'melosVersion': (melosVersion as String?), + if (buildRunnerDetection != _undefined) + 'buildRunnerDetection': (buildRunnerDetection as bool?), + if (buildRunnerCommand != _undefined) + 'buildRunnerCommand': (buildRunnerCommand as String?), + if (preferredRegions != _undefined) + 'preferredRegions': (preferredRegions as List?), + if (flutterWebResourcesCdn != _undefined) + 'flutterWebResourcesCdn': (flutterWebResourcesCdn as bool?), + })); +} + +class _CopyWithStubImpl$Input$ProjectSettingsInput + implements CopyWith$Input$ProjectSettingsInput { + _CopyWithStubImpl$Input$ProjectSettingsInput(this._res); + + TRes _res; + + call({ + Enum$FrameworkPreset? preset, + String? presetVersion, + String? presetBuildCommand, + String? buildImage, + String? buildCommand, + String? entrypoint, + String? rootDirectory, + bool? melosDetection, + String? melosCommand, + String? melosVersion, + bool? buildRunnerDetection, + String? buildRunnerCommand, + List? preferredRegions, + bool? flutterWebResourcesCdn, + }) => + _res; +} + +class Input$ProjectConnectionInput { + factory Input$ProjectConnectionInput({ + required String provider, + required String owner, + required String repository, + required int installationId, + required int repositoryId, + required String branch, + }) => + Input$ProjectConnectionInput._({ + r'provider': provider, + r'owner': owner, + r'repository': repository, + r'installationId': installationId, + r'repositoryId': repositoryId, + r'branch': branch, + }); + + Input$ProjectConnectionInput._(this._$data); + + factory Input$ProjectConnectionInput.fromJson(Map data) { + final result$data = {}; + final l$provider = data['provider']; + result$data['provider'] = (l$provider as String); + final l$owner = data['owner']; + result$data['owner'] = (l$owner as String); + final l$repository = data['repository']; + result$data['repository'] = (l$repository as String); + final l$installationId = data['installationId']; + result$data['installationId'] = (l$installationId as int); + final l$repositoryId = data['repositoryId']; + result$data['repositoryId'] = (l$repositoryId as int); + final l$branch = data['branch']; + result$data['branch'] = (l$branch as String); + return Input$ProjectConnectionInput._(result$data); + } + + Map _$data; + + String get provider => (_$data['provider'] as String); + + String get owner => (_$data['owner'] as String); + + String get repository => (_$data['repository'] as String); + + int get installationId => (_$data['installationId'] as int); + + int get repositoryId => (_$data['repositoryId'] as int); + + String get branch => (_$data['branch'] as String); + + Map toJson() { + final result$data = {}; + final l$provider = provider; + result$data['provider'] = l$provider; + final l$owner = owner; + result$data['owner'] = l$owner; + final l$repository = repository; + result$data['repository'] = l$repository; + final l$installationId = installationId; + result$data['installationId'] = l$installationId; + final l$repositoryId = repositoryId; + result$data['repositoryId'] = l$repositoryId; + final l$branch = branch; + result$data['branch'] = l$branch; + return result$data; + } + + CopyWith$Input$ProjectConnectionInput + get copyWith => CopyWith$Input$ProjectConnectionInput( + this, + (i) => i, + ); + + @override + bool operator ==(Object other) { + if (identical(this, other)) { + return true; + } + if (!(other is Input$ProjectConnectionInput) || + runtimeType != other.runtimeType) { + return false; + } + final l$provider = provider; + final lOther$provider = other.provider; + if (l$provider != lOther$provider) { + return false; + } + final l$owner = owner; + final lOther$owner = other.owner; + if (l$owner != lOther$owner) { + return false; + } + final l$repository = repository; + final lOther$repository = other.repository; + if (l$repository != lOther$repository) { + return false; + } + final l$installationId = installationId; + final lOther$installationId = other.installationId; + if (l$installationId != lOther$installationId) { + return false; + } + final l$repositoryId = repositoryId; + final lOther$repositoryId = other.repositoryId; + if (l$repositoryId != lOther$repositoryId) { + return false; + } + final l$branch = branch; + final lOther$branch = other.branch; + if (l$branch != lOther$branch) { + return false; + } + return true; + } + + @override + int get hashCode { + final l$provider = provider; + final l$owner = owner; + final l$repository = repository; + final l$installationId = installationId; + final l$repositoryId = repositoryId; + final l$branch = branch; + return Object.hashAll([ + l$provider, + l$owner, + l$repository, + l$installationId, + l$repositoryId, + l$branch, + ]); + } +} + +abstract class CopyWith$Input$ProjectConnectionInput { + factory CopyWith$Input$ProjectConnectionInput( + Input$ProjectConnectionInput instance, + TRes Function(Input$ProjectConnectionInput) then, + ) = _CopyWithImpl$Input$ProjectConnectionInput; + + factory CopyWith$Input$ProjectConnectionInput.stub(TRes res) = + _CopyWithStubImpl$Input$ProjectConnectionInput; + + TRes call({ + String? provider, + String? owner, + String? repository, + int? installationId, + int? repositoryId, + String? branch, + }); +} + +class _CopyWithImpl$Input$ProjectConnectionInput + implements CopyWith$Input$ProjectConnectionInput { + _CopyWithImpl$Input$ProjectConnectionInput( + this._instance, + this._then, + ); + + final Input$ProjectConnectionInput _instance; + + final TRes Function(Input$ProjectConnectionInput) _then; + + static const _undefined = {}; + + TRes call({ + Object? provider = _undefined, + Object? owner = _undefined, + Object? repository = _undefined, + Object? installationId = _undefined, + Object? repositoryId = _undefined, + Object? branch = _undefined, + }) => + _then(Input$ProjectConnectionInput._({ + ..._instance._$data, + if (provider != _undefined && provider != null) + 'provider': (provider as String), + if (owner != _undefined && owner != null) 'owner': (owner as String), + if (repository != _undefined && repository != null) + 'repository': (repository as String), + if (installationId != _undefined && installationId != null) + 'installationId': (installationId as int), + if (repositoryId != _undefined && repositoryId != null) + 'repositoryId': (repositoryId as int), + if (branch != _undefined && branch != null) + 'branch': (branch as String), + })); +} + +class _CopyWithStubImpl$Input$ProjectConnectionInput + implements CopyWith$Input$ProjectConnectionInput { + _CopyWithStubImpl$Input$ProjectConnectionInput(this._res); + + TRes _res; + + call({ + String? provider, + String? owner, + String? repository, + int? installationId, + int? repositoryId, + String? branch, + }) => + _res; +} + +class Input$CreateProjectInput { + factory Input$CreateProjectInput({ + required String orgSlug, + required String slug, + Input$ProjectSettingsInput? settings, + Input$ProjectConnectionInput? connection, + }) => + Input$CreateProjectInput._({ + r'orgSlug': orgSlug, + r'slug': slug, + if (settings != null) r'settings': settings, + if (connection != null) r'connection': connection, + }); + + Input$CreateProjectInput._(this._$data); + + factory Input$CreateProjectInput.fromJson(Map data) { + final result$data = {}; + final l$orgSlug = data['orgSlug']; + result$data['orgSlug'] = (l$orgSlug as String); + final l$slug = data['slug']; + result$data['slug'] = (l$slug as String); + if (data.containsKey('settings')) { + final l$settings = data['settings']; + result$data['settings'] = l$settings == null + ? null + : Input$ProjectSettingsInput.fromJson( + (l$settings as Map)); + } + if (data.containsKey('connection')) { + final l$connection = data['connection']; + result$data['connection'] = l$connection == null + ? null + : Input$ProjectConnectionInput.fromJson( + (l$connection as Map)); + } + return Input$CreateProjectInput._(result$data); + } + + Map _$data; + + String get orgSlug => (_$data['orgSlug'] as String); + + String get slug => (_$data['slug'] as String); + + Input$ProjectSettingsInput? get settings => + (_$data['settings'] as Input$ProjectSettingsInput?); + + Input$ProjectConnectionInput? get connection => + (_$data['connection'] as Input$ProjectConnectionInput?); + + Map toJson() { + final result$data = {}; + final l$orgSlug = orgSlug; + result$data['orgSlug'] = l$orgSlug; + final l$slug = slug; + result$data['slug'] = l$slug; + if (_$data.containsKey('settings')) { + final l$settings = settings; + result$data['settings'] = l$settings?.toJson(); + } + if (_$data.containsKey('connection')) { + final l$connection = connection; + result$data['connection'] = l$connection?.toJson(); + } + return result$data; + } + + CopyWith$Input$CreateProjectInput get copyWith => + CopyWith$Input$CreateProjectInput( + this, + (i) => i, + ); + + @override + bool operator ==(Object other) { + if (identical(this, other)) { + return true; + } + if (!(other is Input$CreateProjectInput) || + runtimeType != other.runtimeType) { + return false; + } + final l$orgSlug = orgSlug; + final lOther$orgSlug = other.orgSlug; + if (l$orgSlug != lOther$orgSlug) { + return false; + } + final l$slug = slug; + final lOther$slug = other.slug; + if (l$slug != lOther$slug) { + return false; + } + final l$settings = settings; + final lOther$settings = other.settings; + if (_$data.containsKey('settings') != + other._$data.containsKey('settings')) { + return false; + } + if (l$settings != lOther$settings) { + return false; + } + final l$connection = connection; + final lOther$connection = other.connection; + if (_$data.containsKey('connection') != + other._$data.containsKey('connection')) { + return false; + } + if (l$connection != lOther$connection) { + return false; + } + return true; + } + + @override + int get hashCode { + final l$orgSlug = orgSlug; + final l$slug = slug; + final l$settings = settings; + final l$connection = connection; + return Object.hashAll([ + l$orgSlug, + l$slug, + _$data.containsKey('settings') ? l$settings : const {}, + _$data.containsKey('connection') ? l$connection : const {}, + ]); + } +} + +abstract class CopyWith$Input$CreateProjectInput { + factory CopyWith$Input$CreateProjectInput( + Input$CreateProjectInput instance, + TRes Function(Input$CreateProjectInput) then, + ) = _CopyWithImpl$Input$CreateProjectInput; + + factory CopyWith$Input$CreateProjectInput.stub(TRes res) = + _CopyWithStubImpl$Input$CreateProjectInput; + + TRes call({ + String? orgSlug, + String? slug, + Input$ProjectSettingsInput? settings, + Input$ProjectConnectionInput? connection, + }); + CopyWith$Input$ProjectSettingsInput get settings; + CopyWith$Input$ProjectConnectionInput get connection; +} + +class _CopyWithImpl$Input$CreateProjectInput + implements CopyWith$Input$CreateProjectInput { + _CopyWithImpl$Input$CreateProjectInput( + this._instance, + this._then, + ); + + final Input$CreateProjectInput _instance; + + final TRes Function(Input$CreateProjectInput) _then; + + static const _undefined = {}; + + TRes call({ + Object? orgSlug = _undefined, + Object? slug = _undefined, + Object? settings = _undefined, + Object? connection = _undefined, + }) => + _then(Input$CreateProjectInput._({ + ..._instance._$data, + if (orgSlug != _undefined && orgSlug != null) + 'orgSlug': (orgSlug as String), + if (slug != _undefined && slug != null) 'slug': (slug as String), + if (settings != _undefined) + 'settings': (settings as Input$ProjectSettingsInput?), + if (connection != _undefined) + 'connection': (connection as Input$ProjectConnectionInput?), + })); + + CopyWith$Input$ProjectSettingsInput get settings { + final local$settings = _instance.settings; + return local$settings == null + ? CopyWith$Input$ProjectSettingsInput.stub(_then(_instance)) + : CopyWith$Input$ProjectSettingsInput( + local$settings, (e) => call(settings: e)); + } + + CopyWith$Input$ProjectConnectionInput get connection { + final local$connection = _instance.connection; + return local$connection == null + ? CopyWith$Input$ProjectConnectionInput.stub(_then(_instance)) + : CopyWith$Input$ProjectConnectionInput( + local$connection, (e) => call(connection: e)); + } +} + +class _CopyWithStubImpl$Input$CreateProjectInput + implements CopyWith$Input$CreateProjectInput { + _CopyWithStubImpl$Input$CreateProjectInput(this._res); + + TRes _res; + + call({ + String? orgSlug, + String? slug, + Input$ProjectSettingsInput? settings, + Input$ProjectConnectionInput? connection, + }) => + _res; + + CopyWith$Input$ProjectSettingsInput get settings => + CopyWith$Input$ProjectSettingsInput.stub(_res); + + CopyWith$Input$ProjectConnectionInput get connection => + CopyWith$Input$ProjectConnectionInput.stub(_res); +} + +class Input$UpdateProjectSlugInput { + factory Input$UpdateProjectSlugInput({ + required String orgSlug, + required String slug, + }) => + Input$UpdateProjectSlugInput._({ + r'orgSlug': orgSlug, + r'slug': slug, + }); + + Input$UpdateProjectSlugInput._(this._$data); + + factory Input$UpdateProjectSlugInput.fromJson(Map data) { + final result$data = {}; + final l$orgSlug = data['orgSlug']; + result$data['orgSlug'] = (l$orgSlug as String); + final l$slug = data['slug']; + result$data['slug'] = (l$slug as String); + return Input$UpdateProjectSlugInput._(result$data); + } + + Map _$data; + + String get orgSlug => (_$data['orgSlug'] as String); + + String get slug => (_$data['slug'] as String); + + Map toJson() { + final result$data = {}; + final l$orgSlug = orgSlug; + result$data['orgSlug'] = l$orgSlug; + final l$slug = slug; + result$data['slug'] = l$slug; + return result$data; + } + + CopyWith$Input$UpdateProjectSlugInput + get copyWith => CopyWith$Input$UpdateProjectSlugInput( + this, + (i) => i, + ); + + @override + bool operator ==(Object other) { + if (identical(this, other)) { + return true; + } + if (!(other is Input$UpdateProjectSlugInput) || + runtimeType != other.runtimeType) { + return false; + } + final l$orgSlug = orgSlug; + final lOther$orgSlug = other.orgSlug; + if (l$orgSlug != lOther$orgSlug) { + return false; + } + final l$slug = slug; + final lOther$slug = other.slug; + if (l$slug != lOther$slug) { + return false; + } + return true; + } + + @override + int get hashCode { + final l$orgSlug = orgSlug; + final l$slug = slug; + return Object.hashAll([ + l$orgSlug, + l$slug, + ]); + } +} + +abstract class CopyWith$Input$UpdateProjectSlugInput { + factory CopyWith$Input$UpdateProjectSlugInput( + Input$UpdateProjectSlugInput instance, + TRes Function(Input$UpdateProjectSlugInput) then, + ) = _CopyWithImpl$Input$UpdateProjectSlugInput; + + factory CopyWith$Input$UpdateProjectSlugInput.stub(TRes res) = + _CopyWithStubImpl$Input$UpdateProjectSlugInput; + + TRes call({ + String? orgSlug, + String? slug, + }); +} + +class _CopyWithImpl$Input$UpdateProjectSlugInput + implements CopyWith$Input$UpdateProjectSlugInput { + _CopyWithImpl$Input$UpdateProjectSlugInput( + this._instance, + this._then, + ); + + final Input$UpdateProjectSlugInput _instance; + + final TRes Function(Input$UpdateProjectSlugInput) _then; + + static const _undefined = {}; + + TRes call({ + Object? orgSlug = _undefined, + Object? slug = _undefined, + }) => + _then(Input$UpdateProjectSlugInput._({ + ..._instance._$data, + if (orgSlug != _undefined && orgSlug != null) + 'orgSlug': (orgSlug as String), + if (slug != _undefined && slug != null) 'slug': (slug as String), + })); +} + +class _CopyWithStubImpl$Input$UpdateProjectSlugInput + implements CopyWith$Input$UpdateProjectSlugInput { + _CopyWithStubImpl$Input$UpdateProjectSlugInput(this._res); + + TRes _res; + + call({ + String? orgSlug, + String? slug, + }) => + _res; +} + +enum Enum$FrameworkPreset { + dart_frog, + flutter, + serverpod, + $unknown; + + factory Enum$FrameworkPreset.fromJson(String value) => + fromJson$Enum$FrameworkPreset(value); + + String toJson() => toJson$Enum$FrameworkPreset(this); +} + +String toJson$Enum$FrameworkPreset(Enum$FrameworkPreset e) { + switch (e) { + case Enum$FrameworkPreset.dart_frog: + return r'dart_frog'; + case Enum$FrameworkPreset.flutter: + return r'flutter'; + case Enum$FrameworkPreset.serverpod: + return r'serverpod'; + case Enum$FrameworkPreset.$unknown: + return r'$unknown'; + } +} + +Enum$FrameworkPreset fromJson$Enum$FrameworkPreset(String value) { + switch (value) { + case r'dart_frog': + return Enum$FrameworkPreset.dart_frog; + case r'flutter': + return Enum$FrameworkPreset.flutter; + case r'serverpod': + return Enum$FrameworkPreset.serverpod; + default: + return Enum$FrameworkPreset.$unknown; + } +} + +enum Enum$ProjectStatus { + active, + paused, + marked_for_deletion, + deletion_in_progress, + $unknown; + + factory Enum$ProjectStatus.fromJson(String value) => + fromJson$Enum$ProjectStatus(value); + + String toJson() => toJson$Enum$ProjectStatus(this); +} + +String toJson$Enum$ProjectStatus(Enum$ProjectStatus e) { + switch (e) { + case Enum$ProjectStatus.active: + return r'active'; + case Enum$ProjectStatus.paused: + return r'paused'; + case Enum$ProjectStatus.marked_for_deletion: + return r'marked_for_deletion'; + case Enum$ProjectStatus.deletion_in_progress: + return r'deletion_in_progress'; + case Enum$ProjectStatus.$unknown: + return r'$unknown'; + } +} + +Enum$ProjectStatus fromJson$Enum$ProjectStatus(String value) { + switch (value) { + case r'active': + return Enum$ProjectStatus.active; + case r'paused': + return Enum$ProjectStatus.paused; + case r'marked_for_deletion': + return Enum$ProjectStatus.marked_for_deletion; + case r'deletion_in_progress': + return Enum$ProjectStatus.deletion_in_progress; + default: + return Enum$ProjectStatus.$unknown; + } +} diff --git a/packages/globe_cli/lib/src/graphql/scalars.graphql b/packages/globe_cli/lib/src/graphql/scalars.graphql new file mode 100644 index 0000000..68ab69c --- /dev/null +++ b/packages/globe_cli/lib/src/graphql/scalars.graphql @@ -0,0 +1 @@ +scalar DateTime diff --git a/packages/globe_cli/lib/src/graphql/scalars.graphql.dart b/packages/globe_cli/lib/src/graphql/scalars.graphql.dart new file mode 100644 index 0000000..5f8fc03 --- /dev/null +++ b/packages/globe_cli/lib/src/graphql/scalars.graphql.dart @@ -0,0 +1 @@ +// ignore_for_file: type=lint diff --git a/packages/globe_cli/lib/src/graphql/schema.graphql b/packages/globe_cli/lib/src/graphql/schema.graphql new file mode 100644 index 0000000..74b35aa --- /dev/null +++ b/packages/globe_cli/lib/src/graphql/schema.graphql @@ -0,0 +1,16 @@ +type Query +type Mutation + +type SuccessResponse { + message: String! +} + +enum GlobeApiErrorCode { + INTERNAL_SERVER_ERROR + UNAUTHORIZED + FORBIDDEN + NOT_FOUND + BAD_REQUEST +} + +directive @isAdmin on OBJECT | FIELD_DEFINITION diff --git a/packages/globe_cli/lib/src/graphql/schema.graphql.dart b/packages/globe_cli/lib/src/graphql/schema.graphql.dart new file mode 100644 index 0000000..dc4b863 --- /dev/null +++ b/packages/globe_cli/lib/src/graphql/schema.graphql.dart @@ -0,0 +1,247 @@ +// ignore_for_file: type=lint +enum Enum$GlobeApiErrorCode { + INTERNAL_SERVER_ERROR, + UNAUTHORIZED, + FORBIDDEN, + NOT_FOUND, + BAD_REQUEST, + $unknown; + + factory Enum$GlobeApiErrorCode.fromJson(String value) => + fromJson$Enum$GlobeApiErrorCode(value); + + String toJson() => toJson$Enum$GlobeApiErrorCode(this); +} + +String toJson$Enum$GlobeApiErrorCode(Enum$GlobeApiErrorCode e) { + switch (e) { + case Enum$GlobeApiErrorCode.INTERNAL_SERVER_ERROR: + return r'INTERNAL_SERVER_ERROR'; + case Enum$GlobeApiErrorCode.UNAUTHORIZED: + return r'UNAUTHORIZED'; + case Enum$GlobeApiErrorCode.FORBIDDEN: + return r'FORBIDDEN'; + case Enum$GlobeApiErrorCode.NOT_FOUND: + return r'NOT_FOUND'; + case Enum$GlobeApiErrorCode.BAD_REQUEST: + return r'BAD_REQUEST'; + case Enum$GlobeApiErrorCode.$unknown: + return r'$unknown'; + } +} + +Enum$GlobeApiErrorCode fromJson$Enum$GlobeApiErrorCode(String value) { + switch (value) { + case r'INTERNAL_SERVER_ERROR': + return Enum$GlobeApiErrorCode.INTERNAL_SERVER_ERROR; + case r'UNAUTHORIZED': + return Enum$GlobeApiErrorCode.UNAUTHORIZED; + case r'FORBIDDEN': + return Enum$GlobeApiErrorCode.FORBIDDEN; + case r'NOT_FOUND': + return Enum$GlobeApiErrorCode.NOT_FOUND; + case r'BAD_REQUEST': + return Enum$GlobeApiErrorCode.BAD_REQUEST; + default: + return Enum$GlobeApiErrorCode.$unknown; + } +} + +enum Enum$__TypeKind { + SCALAR, + OBJECT, + INTERFACE, + UNION, + ENUM, + INPUT_OBJECT, + LIST, + NON_NULL, + $unknown; + + factory Enum$__TypeKind.fromJson(String value) => + fromJson$Enum$__TypeKind(value); + + String toJson() => toJson$Enum$__TypeKind(this); +} + +String toJson$Enum$__TypeKind(Enum$__TypeKind e) { + switch (e) { + case Enum$__TypeKind.SCALAR: + return r'SCALAR'; + case Enum$__TypeKind.OBJECT: + return r'OBJECT'; + case Enum$__TypeKind.INTERFACE: + return r'INTERFACE'; + case Enum$__TypeKind.UNION: + return r'UNION'; + case Enum$__TypeKind.ENUM: + return r'ENUM'; + case Enum$__TypeKind.INPUT_OBJECT: + return r'INPUT_OBJECT'; + case Enum$__TypeKind.LIST: + return r'LIST'; + case Enum$__TypeKind.NON_NULL: + return r'NON_NULL'; + case Enum$__TypeKind.$unknown: + return r'$unknown'; + } +} + +Enum$__TypeKind fromJson$Enum$__TypeKind(String value) { + switch (value) { + case r'SCALAR': + return Enum$__TypeKind.SCALAR; + case r'OBJECT': + return Enum$__TypeKind.OBJECT; + case r'INTERFACE': + return Enum$__TypeKind.INTERFACE; + case r'UNION': + return Enum$__TypeKind.UNION; + case r'ENUM': + return Enum$__TypeKind.ENUM; + case r'INPUT_OBJECT': + return Enum$__TypeKind.INPUT_OBJECT; + case r'LIST': + return Enum$__TypeKind.LIST; + case r'NON_NULL': + return Enum$__TypeKind.NON_NULL; + default: + return Enum$__TypeKind.$unknown; + } +} + +enum Enum$__DirectiveLocation { + QUERY, + MUTATION, + SUBSCRIPTION, + FIELD, + FRAGMENT_DEFINITION, + FRAGMENT_SPREAD, + INLINE_FRAGMENT, + VARIABLE_DEFINITION, + SCHEMA, + SCALAR, + OBJECT, + FIELD_DEFINITION, + ARGUMENT_DEFINITION, + INTERFACE, + UNION, + ENUM, + ENUM_VALUE, + INPUT_OBJECT, + INPUT_FIELD_DEFINITION, + $unknown; + + factory Enum$__DirectiveLocation.fromJson(String value) => + fromJson$Enum$__DirectiveLocation(value); + + String toJson() => toJson$Enum$__DirectiveLocation(this); +} + +String toJson$Enum$__DirectiveLocation(Enum$__DirectiveLocation e) { + switch (e) { + case Enum$__DirectiveLocation.QUERY: + return r'QUERY'; + case Enum$__DirectiveLocation.MUTATION: + return r'MUTATION'; + case Enum$__DirectiveLocation.SUBSCRIPTION: + return r'SUBSCRIPTION'; + case Enum$__DirectiveLocation.FIELD: + return r'FIELD'; + case Enum$__DirectiveLocation.FRAGMENT_DEFINITION: + return r'FRAGMENT_DEFINITION'; + case Enum$__DirectiveLocation.FRAGMENT_SPREAD: + return r'FRAGMENT_SPREAD'; + case Enum$__DirectiveLocation.INLINE_FRAGMENT: + return r'INLINE_FRAGMENT'; + case Enum$__DirectiveLocation.VARIABLE_DEFINITION: + return r'VARIABLE_DEFINITION'; + case Enum$__DirectiveLocation.SCHEMA: + return r'SCHEMA'; + case Enum$__DirectiveLocation.SCALAR: + return r'SCALAR'; + case Enum$__DirectiveLocation.OBJECT: + return r'OBJECT'; + case Enum$__DirectiveLocation.FIELD_DEFINITION: + return r'FIELD_DEFINITION'; + case Enum$__DirectiveLocation.ARGUMENT_DEFINITION: + return r'ARGUMENT_DEFINITION'; + case Enum$__DirectiveLocation.INTERFACE: + return r'INTERFACE'; + case Enum$__DirectiveLocation.UNION: + return r'UNION'; + case Enum$__DirectiveLocation.ENUM: + return r'ENUM'; + case Enum$__DirectiveLocation.ENUM_VALUE: + return r'ENUM_VALUE'; + case Enum$__DirectiveLocation.INPUT_OBJECT: + return r'INPUT_OBJECT'; + case Enum$__DirectiveLocation.INPUT_FIELD_DEFINITION: + return r'INPUT_FIELD_DEFINITION'; + case Enum$__DirectiveLocation.$unknown: + return r'$unknown'; + } +} + +Enum$__DirectiveLocation fromJson$Enum$__DirectiveLocation(String value) { + switch (value) { + case r'QUERY': + return Enum$__DirectiveLocation.QUERY; + case r'MUTATION': + return Enum$__DirectiveLocation.MUTATION; + case r'SUBSCRIPTION': + return Enum$__DirectiveLocation.SUBSCRIPTION; + case r'FIELD': + return Enum$__DirectiveLocation.FIELD; + case r'FRAGMENT_DEFINITION': + return Enum$__DirectiveLocation.FRAGMENT_DEFINITION; + case r'FRAGMENT_SPREAD': + return Enum$__DirectiveLocation.FRAGMENT_SPREAD; + case r'INLINE_FRAGMENT': + return Enum$__DirectiveLocation.INLINE_FRAGMENT; + case r'VARIABLE_DEFINITION': + return Enum$__DirectiveLocation.VARIABLE_DEFINITION; + case r'SCHEMA': + return Enum$__DirectiveLocation.SCHEMA; + case r'SCALAR': + return Enum$__DirectiveLocation.SCALAR; + case r'OBJECT': + return Enum$__DirectiveLocation.OBJECT; + case r'FIELD_DEFINITION': + return Enum$__DirectiveLocation.FIELD_DEFINITION; + case r'ARGUMENT_DEFINITION': + return Enum$__DirectiveLocation.ARGUMENT_DEFINITION; + case r'INTERFACE': + return Enum$__DirectiveLocation.INTERFACE; + case r'UNION': + return Enum$__DirectiveLocation.UNION; + case r'ENUM': + return Enum$__DirectiveLocation.ENUM; + case r'ENUM_VALUE': + return Enum$__DirectiveLocation.ENUM_VALUE; + case r'INPUT_OBJECT': + return Enum$__DirectiveLocation.INPUT_OBJECT; + case r'INPUT_FIELD_DEFINITION': + return Enum$__DirectiveLocation.INPUT_FIELD_DEFINITION; + default: + return Enum$__DirectiveLocation.$unknown; + } +} + +const possibleTypesMap = >{ + 'Entity': { + 'Project', + 'Organization', + 'Deployment', + 'GlobeUser', + }, + 'User': { + 'Me', + 'GlobeUser', + 'OrganizationMember', + }, + 'IToken': { + 'Token', + 'TokenWithValue', + }, +}; diff --git a/packages/globe_cli/lib/src/graphql/statistics.graphql b/packages/globe_cli/lib/src/graphql/statistics.graphql new file mode 100644 index 0000000..805afcb --- /dev/null +++ b/packages/globe_cli/lib/src/graphql/statistics.graphql @@ -0,0 +1,34 @@ +enum Interval { + Day + Week + Month +} + +type DataPoint { + date: DateTime! + count: Int! +} + +type DeploymentStat { + date: DateTime! + success: Int! + """ + This combines pending, working & deploying deployment states. + """ + pending: Int! + error: Int! +} + +extend type Query { + userSignupStats( + startDate: DateTime! + endDate: DateTime! + interval: Interval = Month + ): [DataPoint!]! @isAdmin + + latestDeploymentStats( + startDate: DateTime! + endDate: DateTime! + interval: Interval = Month + ): [DeploymentStat!]! @isAdmin +} diff --git a/packages/globe_cli/lib/src/graphql/statistics.graphql.dart b/packages/globe_cli/lib/src/graphql/statistics.graphql.dart new file mode 100644 index 0000000..f1b4671 --- /dev/null +++ b/packages/globe_cli/lib/src/graphql/statistics.graphql.dart @@ -0,0 +1,37 @@ +// ignore_for_file: type=lint +enum Enum$Interval { + Day, + Week, + Month, + $unknown; + + factory Enum$Interval.fromJson(String value) => fromJson$Enum$Interval(value); + + String toJson() => toJson$Enum$Interval(this); +} + +String toJson$Enum$Interval(Enum$Interval e) { + switch (e) { + case Enum$Interval.Day: + return r'Day'; + case Enum$Interval.Week: + return r'Week'; + case Enum$Interval.Month: + return r'Month'; + case Enum$Interval.$unknown: + return r'$unknown'; + } +} + +Enum$Interval fromJson$Enum$Interval(String value) { + switch (value) { + case r'Day': + return Enum$Interval.Day; + case r'Week': + return Enum$Interval.Week; + case r'Month': + return Enum$Interval.Month; + default: + return Enum$Interval.$unknown; + } +} diff --git a/packages/globe_cli/lib/src/graphql/token.graphql b/packages/globe_cli/lib/src/graphql/token.graphql new file mode 100644 index 0000000..210534f --- /dev/null +++ b/packages/globe_cli/lib/src/graphql/token.graphql @@ -0,0 +1,43 @@ +interface IToken { + uuid: String! + name: String! + organizationUuid: String! + createdAt: DateTime! + expiresAt: DateTime! + projects: [String!]! +} + +type Token implements IToken { + uuid: String! + name: String! + organizationUuid: String! + createdAt: DateTime! + expiresAt: DateTime! + projects: [String!]! +} + +type TokenWithValue implements IToken { + uuid: String! + name: String! + organizationUuid: String! + createdAt: DateTime! + expiresAt: DateTime! + projects: [String!]! + value: String! +} + +extend type Query { + token(orgSlug: String!, uuid: String!): Token! + tokens(orgSlug: String!, projects: [String!]): [Token!]! +} + +extend type Mutation { + createToken( + orgSlug: String! + name: String! + expiresAt: DateTime! + projects: [String!]! + ): TokenWithValue! + updateToken(orgSlug: String!, uuid: String!, projects: [String!]!): Token! + deleteToken(orgSlug: String!, uuid: String!): SuccessResponse! +} diff --git a/packages/globe_cli/lib/src/graphql/token.graphql.dart b/packages/globe_cli/lib/src/graphql/token.graphql.dart new file mode 100644 index 0000000..5f8fc03 --- /dev/null +++ b/packages/globe_cli/lib/src/graphql/token.graphql.dart @@ -0,0 +1 @@ +// ignore_for_file: type=lint From f84d0edd95160df7c4ccdbf1d1190a9f555c08e9 Mon Sep 17 00:00:00 2001 From: Remi Rousselet Date: Thu, 1 Aug 2024 14:53:48 +0200 Subject: [PATCH 2/7] Add graphql_codegen --- packages/globe_cli/.graphqlrc.yml | 3 + packages/globe_cli/build.yaml | 10 ++ packages/globe_cli/pubspec.lock | 168 +++++++++++++++++++++++++++--- packages/globe_cli/pubspec.yaml | 6 +- 4 files changed, 174 insertions(+), 13 deletions(-) create mode 100644 packages/globe_cli/.graphqlrc.yml create mode 100644 packages/globe_cli/build.yaml diff --git a/packages/globe_cli/.graphqlrc.yml b/packages/globe_cli/.graphqlrc.yml new file mode 100644 index 0000000..c61fa68 --- /dev/null +++ b/packages/globe_cli/.graphqlrc.yml @@ -0,0 +1,3 @@ +# .graphqlrc.yml or graphql.config.yml +schema: "lib/src/graphql/**/*.graphql" +documents: "lib/**/*.graphql" diff --git a/packages/globe_cli/build.yaml b/packages/globe_cli/build.yaml new file mode 100644 index 0000000..c139146 --- /dev/null +++ b/packages/globe_cli/build.yaml @@ -0,0 +1,10 @@ +# build.yaml + +targets: + $default: + builders: + graphql_codegen: + options: + generatedFileHeader: "// ignore_for_file: type=lint\n" + clients: + - graphql diff --git a/packages/globe_cli/pubspec.lock b/packages/globe_cli/pubspec.lock index 17d213a..5e27707 100644 --- a/packages/globe_cli/pubspec.lock +++ b/packages/globe_cli/pubspec.lock @@ -118,6 +118,14 @@ packages: url: "https://pub.dev" source: hosted version: "8.9.2" + built_value_generator: + dependency: transitive + description: + name: built_value_generator + sha256: bb06c5e9dbdbd35ed6de21520e2e5112582c964fa584e2a4bb59887fc7a169b0 + url: "https://pub.dev" + source: hosted + version: "8.9.2" checked_yaml: dependency: transitive description: @@ -198,6 +206,22 @@ packages: url: "https://pub.dev" source: hosted version: "2.0.5" + ferry_exec: + dependency: transitive + description: + name: ferry_exec + sha256: dfa916794065e65f35842b716026fe6ed930dc41d3ad49496204f0ef7da55c2d + url: "https://pub.dev" + source: hosted + version: "0.5.0" + ferry_generator: + dependency: "direct dev" + description: + name: ferry_generator + sha256: "9e9cdb001661261cbb5aa84cbdf6346f9ece5d5ef64fcc55915479f372524cf0" + url: "https://pub.dev" + source: hosted + version: "0.9.1-dev.0" ffi: dependency: transitive description: @@ -261,6 +285,94 @@ packages: relative: true source: path version: "1.0.1" + gql: + dependency: transitive + description: + name: gql + sha256: "8ecd3585bb9e40d671aa58f52575d950670f99e5ffab18e2b34a757e071a6693" + url: "https://pub.dev" + source: hosted + version: "1.0.1-alpha+1717789143880" + gql_code_builder: + dependency: transitive + description: + name: gql_code_builder + sha256: b70e17fe62af58c3a9a3dfd619bf0b07ca15afe4d285001fbcd0852a40538401 + url: "https://pub.dev" + source: hosted + version: "0.9.1+1" + gql_dedupe_link: + dependency: transitive + description: + name: gql_dedupe_link + sha256: "10bee0564d67c24e0c8bd08bd56e0682b64a135e58afabbeed30d85d5e9fea96" + url: "https://pub.dev" + source: hosted + version: "2.0.4-alpha+1715521079596" + gql_error_link: + dependency: transitive + description: + name: gql_error_link + sha256: "93901458f3c050e33386dedb0ca7173e08cebd7078e4e0deca4bf23ab7a71f63" + url: "https://pub.dev" + source: hosted + version: "1.0.0+1" + gql_exec: + dependency: transitive + description: + name: gql_exec + sha256: "394944626fae900f1d34343ecf2d62e44eb984826189c8979d305f0ae5846e38" + url: "https://pub.dev" + source: hosted + version: "1.1.1-alpha+1699813812660" + gql_http_link: + dependency: "direct main" + description: + name: gql_http_link + sha256: ef6ad24d31beb5a30113e9b919eec20876903cc4b0ee0d31550047aaaba7d5dd + url: "https://pub.dev" + source: hosted + version: "1.1.0" + gql_link: + dependency: transitive + description: + name: gql_link + sha256: "70fd5b5cbcc50601679f4b9fea3bcc994e583f59cfec7e1fec11113074b1a565" + url: "https://pub.dev" + source: hosted + version: "1.0.1-alpha+1717789143896" + gql_transform_link: + dependency: transitive + description: + name: gql_transform_link + sha256: "0645fdd874ca1be695fd327271fdfb24c0cd6fa40774a64b946062f321a59709" + url: "https://pub.dev" + source: hosted + version: "1.0.0" + gql_tristate_value: + dependency: transitive + description: + name: gql_tristate_value + sha256: ae045e7e272fbfd030084315140c683c9b032a9861a37165f68c2ecd8a759664 + url: "https://pub.dev" + source: hosted + version: "1.0.0" + graphql: + dependency: "direct main" + description: + name: graphql + sha256: ad11e6d12de4d73971ae1dd80885b09f3cbc0bf143b1cbc5622a6dc6d85735e7 + url: "https://pub.dev" + source: hosted + version: "5.2.0-beta.4" + graphql_codegen: + dependency: "direct dev" + description: + name: graphql_codegen + sha256: d984935993e5fbbd37358eb6dc47e5feacc49fe731c227db47967474f9da6034 + url: "https://pub.dev" + source: hosted + version: "0.14.0" graphs: dependency: transitive description: @@ -269,6 +381,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.3.1" + hive: + dependency: transitive + description: + name: hive + sha256: "8dcf6db979d7933da8217edcec84e9df1bdb4e4edc7fc77dbd5aa74356d6d941" + url: "https://pub.dev" + source: hosted + version: "2.2.3" http: dependency: "direct main" description: @@ -389,6 +509,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.0.2" + normalize: + dependency: transitive + description: + name: normalize + sha256: "8a60e37de5b608eeaf9b839273370c71ebba445e9f73b08eee7725e0d92dbc43" + url: "https://pub.dev" + source: hosted + version: "0.8.2+1" package_config: dependency: transitive description: @@ -453,6 +581,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.0" + recase: + dependency: transitive + description: + name: recase + sha256: e4eb4ec2dcdee52dcf99cb4ceabaffc631d7424ee55e56f280bc039737f89213 + url: "https://pub.dev" + source: hosted + version: "4.1.0" + rxdart: + dependency: transitive + description: + name: rxdart + sha256: "0c7c0cedd93788d996e33041ffecda924cc54389199cde4e6a34b440f50044cb" + url: "https://pub.dev" + source: hosted + version: "0.27.7" shelf: dependency: transitive description: @@ -597,6 +741,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.2" + uuid: + dependency: transitive + description: + name: uuid + sha256: "648e103079f7c64a36dc7d39369cabb358d377078a051d6ae2ad3aa539519313" + url: "https://pub.dev" + source: hosted + version: "3.0.7" vm_service: dependency: transitive description: @@ -617,26 +769,18 @@ packages: dependency: transitive description: name: web - sha256: d43c1d6b787bf0afad444700ae7f4db8827f701bc61c255ac8d328c6f4d52062 - url: "https://pub.dev" - source: hosted - version: "1.0.0" - web_socket: - dependency: transitive - description: - name: web_socket - sha256: "3c12d96c0c9a4eec095246debcea7b86c0324f22df69893d538fcc6f1b8cce83" + sha256: "97da13628db363c635202ad97068d47c5b8aa555808e7a9411963c533b449b27" url: "https://pub.dev" source: hosted - version: "0.1.6" + version: "0.5.1" web_socket_channel: dependency: transitive description: name: web_socket_channel - sha256: "9f187088ed104edd8662ca07af4b124465893caf063ba29758f97af57e61da8f" + sha256: "58c6666b342a38816b2e7e50ed0f1e261959630becd4c879c4f26bfa14aa5a42" url: "https://pub.dev" source: hosted - version: "3.0.1" + version: "2.4.5" webkit_inspection_protocol: dependency: transitive description: diff --git a/packages/globe_cli/pubspec.yaml b/packages/globe_cli/pubspec.yaml index 1442967..9ea2fad 100644 --- a/packages/globe_cli/pubspec.yaml +++ b/packages/globe_cli/pubspec.yaml @@ -20,11 +20,14 @@ dependencies: pub_updater: ^0.3.0 pubspec_parse: ^1.2.3 pool: ^1.5.1 + graphql: ^5.1.3 + gql_http_link: ^1.1.0 dev_dependencies: - build_runner: ^2.4.4 + build_runner: ^2.4.11 file_testing: ^3.0.0 globe_lints: + graphql_codegen: ^0.14.0 mockito: ^5.4.2 # Minimum version compatible with Dart 3.0.0 test: ^1.22.1 @@ -46,6 +49,7 @@ dev_dependencies: watcher: ^1.1.0 # Transitive dependency. Uses removed Platform method otherwise platform: ^3.1.0 + ferry_generator: ^0.9.1-dev.0 executables: globe: globe From e546df4debc23e953de1909e01e8f2c7f4979f88 Mon Sep 17 00:00:00 2001 From: Remi Rousselet Date: Thu, 1 Aug 2024 14:54:28 +0200 Subject: [PATCH 3/7] Migrate API to graphql --- .../lib/src/commands/organizations.graphql | 7 + .../src/commands/organizations.graphql.dart | 501 ++++ .../lib/src/commands/project/project.graphql | 27 + .../src/commands/project/project.graphql.dart | 2323 +++++++++++++++++ .../project/project_pause_command.dart | 9 +- .../project/project_resume_command.dart | 4 +- .../lib/src/commands/token/token.graphql | 30 + .../lib/src/commands/token/token.graphql.dart | 1875 +++++++++++++ .../commands/token/token_create_command.dart | 2 +- .../commands/token/token_delete_command.dart | 2 +- .../commands/token/token_list_command.dart | 7 +- packages/globe_cli/lib/src/utils/api.dart | 363 ++- packages/globe_cli/lib/src/utils/prompts.dart | 8 +- packages/globe_cli/test/mocks.dart | 8 +- .../project/project_resume_command_test.dart | 22 +- 15 files changed, 4959 insertions(+), 229 deletions(-) create mode 100644 packages/globe_cli/lib/src/commands/organizations.graphql create mode 100644 packages/globe_cli/lib/src/commands/organizations.graphql.dart create mode 100644 packages/globe_cli/lib/src/commands/project/project.graphql create mode 100644 packages/globe_cli/lib/src/commands/project/project.graphql.dart create mode 100644 packages/globe_cli/lib/src/commands/token/token.graphql create mode 100644 packages/globe_cli/lib/src/commands/token/token.graphql.dart diff --git a/packages/globe_cli/lib/src/commands/organizations.graphql b/packages/globe_cli/lib/src/commands/organizations.graphql new file mode 100644 index 0000000..b1d8576 --- /dev/null +++ b/packages/globe_cli/lib/src/commands/organizations.graphql @@ -0,0 +1,7 @@ +query Organizations { + organizations { + id + slug + name + } +} diff --git a/packages/globe_cli/lib/src/commands/organizations.graphql.dart b/packages/globe_cli/lib/src/commands/organizations.graphql.dart new file mode 100644 index 0000000..11490cf --- /dev/null +++ b/packages/globe_cli/lib/src/commands/organizations.graphql.dart @@ -0,0 +1,501 @@ +// ignore_for_file: type=lint +import 'dart:async'; +import 'package:gql/ast.dart'; +import 'package:graphql/client.dart' as graphql; + +class Query$Organizations { + Query$Organizations({ + this.organizations, + this.$__typename = 'Query', + }); + + factory Query$Organizations.fromJson(Map json) { + final l$organizations = json['organizations']; + final l$$__typename = json['__typename']; + return Query$Organizations( + organizations: (l$organizations as List?) + ?.map((e) => Query$Organizations$organizations.fromJson( + (e as Map))) + .toList(), + $__typename: (l$$__typename as String), + ); + } + + final List? organizations; + + final String $__typename; + + Map toJson() { + final _resultData = {}; + final l$organizations = organizations; + _resultData['organizations'] = + l$organizations?.map((e) => e.toJson()).toList(); + final l$$__typename = $__typename; + _resultData['__typename'] = l$$__typename; + return _resultData; + } + + @override + int get hashCode { + final l$organizations = organizations; + final l$$__typename = $__typename; + return Object.hashAll([ + l$organizations == null + ? null + : Object.hashAll(l$organizations.map((v) => v)), + l$$__typename, + ]); + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) { + return true; + } + if (!(other is Query$Organizations) || runtimeType != other.runtimeType) { + return false; + } + final l$organizations = organizations; + final lOther$organizations = other.organizations; + if (l$organizations != null && lOther$organizations != null) { + if (l$organizations.length != lOther$organizations.length) { + return false; + } + for (int i = 0; i < l$organizations.length; i++) { + final l$organizations$entry = l$organizations[i]; + final lOther$organizations$entry = lOther$organizations[i]; + if (l$organizations$entry != lOther$organizations$entry) { + return false; + } + } + } else if (l$organizations != lOther$organizations) { + return false; + } + final l$$__typename = $__typename; + final lOther$$__typename = other.$__typename; + if (l$$__typename != lOther$$__typename) { + return false; + } + return true; + } +} + +extension UtilityExtension$Query$Organizations on Query$Organizations { + CopyWith$Query$Organizations get copyWith => + CopyWith$Query$Organizations( + this, + (i) => i, + ); +} + +abstract class CopyWith$Query$Organizations { + factory CopyWith$Query$Organizations( + Query$Organizations instance, + TRes Function(Query$Organizations) then, + ) = _CopyWithImpl$Query$Organizations; + + factory CopyWith$Query$Organizations.stub(TRes res) = + _CopyWithStubImpl$Query$Organizations; + + TRes call({ + List? organizations, + String? $__typename, + }); + TRes organizations( + Iterable? Function( + Iterable< + CopyWith$Query$Organizations$organizations< + Query$Organizations$organizations>>?) + _fn); +} + +class _CopyWithImpl$Query$Organizations + implements CopyWith$Query$Organizations { + _CopyWithImpl$Query$Organizations( + this._instance, + this._then, + ); + + final Query$Organizations _instance; + + final TRes Function(Query$Organizations) _then; + + static const _undefined = {}; + + TRes call({ + Object? organizations = _undefined, + Object? $__typename = _undefined, + }) => + _then(Query$Organizations( + organizations: organizations == _undefined + ? _instance.organizations + : (organizations as List?), + $__typename: $__typename == _undefined || $__typename == null + ? _instance.$__typename + : ($__typename as String), + )); + + TRes organizations( + Iterable? Function( + Iterable< + CopyWith$Query$Organizations$organizations< + Query$Organizations$organizations>>?) + _fn) => + call( + organizations: _fn(_instance.organizations + ?.map((e) => CopyWith$Query$Organizations$organizations( + e, + (i) => i, + )))?.toList()); +} + +class _CopyWithStubImpl$Query$Organizations + implements CopyWith$Query$Organizations { + _CopyWithStubImpl$Query$Organizations(this._res); + + TRes _res; + + call({ + List? organizations, + String? $__typename, + }) => + _res; + + organizations(_fn) => _res; +} + +const documentNodeQueryOrganizations = DocumentNode(definitions: [ + OperationDefinitionNode( + type: OperationType.query, + name: NameNode(value: 'Organizations'), + variableDefinitions: [], + directives: [], + selectionSet: SelectionSetNode(selections: [ + FieldNode( + name: NameNode(value: 'organizations'), + alias: null, + arguments: [], + directives: [], + selectionSet: SelectionSetNode(selections: [ + FieldNode( + name: NameNode(value: 'id'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + FieldNode( + name: NameNode(value: 'slug'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + FieldNode( + name: NameNode(value: 'name'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + FieldNode( + name: NameNode(value: '__typename'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + ]), + ), + FieldNode( + name: NameNode(value: '__typename'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + ]), + ), +]); +Query$Organizations _parserFn$Query$Organizations(Map data) => + Query$Organizations.fromJson(data); +typedef OnQueryComplete$Query$Organizations = FutureOr Function( + Map?, + Query$Organizations?, +); + +class Options$Query$Organizations + extends graphql.QueryOptions { + Options$Query$Organizations({ + String? operationName, + graphql.FetchPolicy? fetchPolicy, + graphql.ErrorPolicy? errorPolicy, + graphql.CacheRereadPolicy? cacheRereadPolicy, + Object? optimisticResult, + Query$Organizations? typedOptimisticResult, + Duration? pollInterval, + graphql.Context? context, + OnQueryComplete$Query$Organizations? onComplete, + graphql.OnQueryError? onError, + }) : onCompleteWithParsed = onComplete, + super( + operationName: operationName, + fetchPolicy: fetchPolicy, + errorPolicy: errorPolicy, + cacheRereadPolicy: cacheRereadPolicy, + optimisticResult: optimisticResult ?? typedOptimisticResult?.toJson(), + pollInterval: pollInterval, + context: context, + onComplete: onComplete == null + ? null + : (data) => onComplete( + data, + data == null ? null : _parserFn$Query$Organizations(data), + ), + onError: onError, + document: documentNodeQueryOrganizations, + parserFn: _parserFn$Query$Organizations, + ); + + final OnQueryComplete$Query$Organizations? onCompleteWithParsed; + + @override + List get properties => [ + ...super.onComplete == null + ? super.properties + : super.properties.where((property) => property != onComplete), + onCompleteWithParsed, + ]; +} + +class WatchOptions$Query$Organizations + extends graphql.WatchQueryOptions { + WatchOptions$Query$Organizations({ + String? operationName, + graphql.FetchPolicy? fetchPolicy, + graphql.ErrorPolicy? errorPolicy, + graphql.CacheRereadPolicy? cacheRereadPolicy, + Object? optimisticResult, + Query$Organizations? typedOptimisticResult, + graphql.Context? context, + Duration? pollInterval, + bool? eagerlyFetchResults, + bool carryForwardDataOnException = true, + bool fetchResults = false, + }) : super( + operationName: operationName, + fetchPolicy: fetchPolicy, + errorPolicy: errorPolicy, + cacheRereadPolicy: cacheRereadPolicy, + optimisticResult: optimisticResult ?? typedOptimisticResult?.toJson(), + context: context, + document: documentNodeQueryOrganizations, + pollInterval: pollInterval, + eagerlyFetchResults: eagerlyFetchResults, + carryForwardDataOnException: carryForwardDataOnException, + fetchResults: fetchResults, + parserFn: _parserFn$Query$Organizations, + ); +} + +class FetchMoreOptions$Query$Organizations extends graphql.FetchMoreOptions { + FetchMoreOptions$Query$Organizations( + {required graphql.UpdateQuery updateQuery}) + : super( + updateQuery: updateQuery, + document: documentNodeQueryOrganizations, + ); +} + +extension ClientExtension$Query$Organizations on graphql.GraphQLClient { + Future> query$Organizations( + [Options$Query$Organizations? options]) async => + await this.query(options ?? Options$Query$Organizations()); + graphql.ObservableQuery watchQuery$Organizations( + [WatchOptions$Query$Organizations? options]) => + this.watchQuery(options ?? WatchOptions$Query$Organizations()); + void writeQuery$Organizations({ + required Query$Organizations data, + bool broadcast = true, + }) => + this.writeQuery( + graphql.Request( + operation: + graphql.Operation(document: documentNodeQueryOrganizations)), + data: data.toJson(), + broadcast: broadcast, + ); + Query$Organizations? readQuery$Organizations({bool optimistic = true}) { + final result = this.readQuery( + graphql.Request( + operation: + graphql.Operation(document: documentNodeQueryOrganizations)), + optimistic: optimistic, + ); + return result == null ? null : Query$Organizations.fromJson(result); + } +} + +class Query$Organizations$organizations { + Query$Organizations$organizations({ + required this.id, + required this.slug, + required this.name, + this.$__typename = 'Organization', + }); + + factory Query$Organizations$organizations.fromJson( + Map json) { + final l$id = json['id']; + final l$slug = json['slug']; + final l$name = json['name']; + final l$$__typename = json['__typename']; + return Query$Organizations$organizations( + id: (l$id as String), + slug: (l$slug as String), + name: (l$name as String), + $__typename: (l$$__typename as String), + ); + } + + final String id; + + final String slug; + + final String name; + + final String $__typename; + + Map toJson() { + final _resultData = {}; + final l$id = id; + _resultData['id'] = l$id; + final l$slug = slug; + _resultData['slug'] = l$slug; + final l$name = name; + _resultData['name'] = l$name; + final l$$__typename = $__typename; + _resultData['__typename'] = l$$__typename; + return _resultData; + } + + @override + int get hashCode { + final l$id = id; + final l$slug = slug; + final l$name = name; + final l$$__typename = $__typename; + return Object.hashAll([ + l$id, + l$slug, + l$name, + l$$__typename, + ]); + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) { + return true; + } + if (!(other is Query$Organizations$organizations) || + runtimeType != other.runtimeType) { + return false; + } + final l$id = id; + final lOther$id = other.id; + if (l$id != lOther$id) { + return false; + } + final l$slug = slug; + final lOther$slug = other.slug; + if (l$slug != lOther$slug) { + return false; + } + final l$name = name; + final lOther$name = other.name; + if (l$name != lOther$name) { + return false; + } + final l$$__typename = $__typename; + final lOther$$__typename = other.$__typename; + if (l$$__typename != lOther$$__typename) { + return false; + } + return true; + } +} + +extension UtilityExtension$Query$Organizations$organizations + on Query$Organizations$organizations { + CopyWith$Query$Organizations$organizations + get copyWith => CopyWith$Query$Organizations$organizations( + this, + (i) => i, + ); +} + +abstract class CopyWith$Query$Organizations$organizations { + factory CopyWith$Query$Organizations$organizations( + Query$Organizations$organizations instance, + TRes Function(Query$Organizations$organizations) then, + ) = _CopyWithImpl$Query$Organizations$organizations; + + factory CopyWith$Query$Organizations$organizations.stub(TRes res) = + _CopyWithStubImpl$Query$Organizations$organizations; + + TRes call({ + String? id, + String? slug, + String? name, + String? $__typename, + }); +} + +class _CopyWithImpl$Query$Organizations$organizations + implements CopyWith$Query$Organizations$organizations { + _CopyWithImpl$Query$Organizations$organizations( + this._instance, + this._then, + ); + + final Query$Organizations$organizations _instance; + + final TRes Function(Query$Organizations$organizations) _then; + + static const _undefined = {}; + + TRes call({ + Object? id = _undefined, + Object? slug = _undefined, + Object? name = _undefined, + Object? $__typename = _undefined, + }) => + _then(Query$Organizations$organizations( + id: id == _undefined || id == null ? _instance.id : (id as String), + slug: slug == _undefined || slug == null + ? _instance.slug + : (slug as String), + name: name == _undefined || name == null + ? _instance.name + : (name as String), + $__typename: $__typename == _undefined || $__typename == null + ? _instance.$__typename + : ($__typename as String), + )); +} + +class _CopyWithStubImpl$Query$Organizations$organizations + implements CopyWith$Query$Organizations$organizations { + _CopyWithStubImpl$Query$Organizations$organizations(this._res); + + TRes _res; + + call({ + String? id, + String? slug, + String? name, + String? $__typename, + }) => + _res; +} diff --git a/packages/globe_cli/lib/src/commands/project/project.graphql b/packages/globe_cli/lib/src/commands/project/project.graphql new file mode 100644 index 0000000..6845723 --- /dev/null +++ b/packages/globe_cli/lib/src/commands/project/project.graphql @@ -0,0 +1,27 @@ +mutation Pause($orgSlug: String!, $projectId: String!) { + pauseProject(orgSlug: $orgSlug, projectId: $projectId) { + message + } +} + +mutation Resume($orgSlug: String!, $projectId: String!) { + resumeProject(orgSlug: $orgSlug, projectId: $projectId) { + message + } +} + +mutation CreateProject($orgSlug: String!, $name: String!) { + createProject(input: { slug: $name, orgSlug: $orgSlug }) { + id + slug + status + } +} + +query Projects($orgSlug: String!) { + projects(orgSlug: $orgSlug) { + id + slug + status + } +} diff --git a/packages/globe_cli/lib/src/commands/project/project.graphql.dart b/packages/globe_cli/lib/src/commands/project/project.graphql.dart new file mode 100644 index 0000000..7748f7b --- /dev/null +++ b/packages/globe_cli/lib/src/commands/project/project.graphql.dart @@ -0,0 +1,2323 @@ +// ignore_for_file: type=lint +import '../../graphql/project.graphql.dart'; +import 'dart:async'; +import 'package:gql/ast.dart'; +import 'package:graphql/client.dart' as graphql; + +class Variables$Mutation$Pause { + factory Variables$Mutation$Pause({ + required String orgSlug, + required String projectId, + }) => + Variables$Mutation$Pause._({ + r'orgSlug': orgSlug, + r'projectId': projectId, + }); + + Variables$Mutation$Pause._(this._$data); + + factory Variables$Mutation$Pause.fromJson(Map data) { + final result$data = {}; + final l$orgSlug = data['orgSlug']; + result$data['orgSlug'] = (l$orgSlug as String); + final l$projectId = data['projectId']; + result$data['projectId'] = (l$projectId as String); + return Variables$Mutation$Pause._(result$data); + } + + Map _$data; + + String get orgSlug => (_$data['orgSlug'] as String); + + String get projectId => (_$data['projectId'] as String); + + Map toJson() { + final result$data = {}; + final l$orgSlug = orgSlug; + result$data['orgSlug'] = l$orgSlug; + final l$projectId = projectId; + result$data['projectId'] = l$projectId; + return result$data; + } + + CopyWith$Variables$Mutation$Pause get copyWith => + CopyWith$Variables$Mutation$Pause( + this, + (i) => i, + ); + + @override + bool operator ==(Object other) { + if (identical(this, other)) { + return true; + } + if (!(other is Variables$Mutation$Pause) || + runtimeType != other.runtimeType) { + return false; + } + final l$orgSlug = orgSlug; + final lOther$orgSlug = other.orgSlug; + if (l$orgSlug != lOther$orgSlug) { + return false; + } + final l$projectId = projectId; + final lOther$projectId = other.projectId; + if (l$projectId != lOther$projectId) { + return false; + } + return true; + } + + @override + int get hashCode { + final l$orgSlug = orgSlug; + final l$projectId = projectId; + return Object.hashAll([ + l$orgSlug, + l$projectId, + ]); + } +} + +abstract class CopyWith$Variables$Mutation$Pause { + factory CopyWith$Variables$Mutation$Pause( + Variables$Mutation$Pause instance, + TRes Function(Variables$Mutation$Pause) then, + ) = _CopyWithImpl$Variables$Mutation$Pause; + + factory CopyWith$Variables$Mutation$Pause.stub(TRes res) = + _CopyWithStubImpl$Variables$Mutation$Pause; + + TRes call({ + String? orgSlug, + String? projectId, + }); +} + +class _CopyWithImpl$Variables$Mutation$Pause + implements CopyWith$Variables$Mutation$Pause { + _CopyWithImpl$Variables$Mutation$Pause( + this._instance, + this._then, + ); + + final Variables$Mutation$Pause _instance; + + final TRes Function(Variables$Mutation$Pause) _then; + + static const _undefined = {}; + + TRes call({ + Object? orgSlug = _undefined, + Object? projectId = _undefined, + }) => + _then(Variables$Mutation$Pause._({ + ..._instance._$data, + if (orgSlug != _undefined && orgSlug != null) + 'orgSlug': (orgSlug as String), + if (projectId != _undefined && projectId != null) + 'projectId': (projectId as String), + })); +} + +class _CopyWithStubImpl$Variables$Mutation$Pause + implements CopyWith$Variables$Mutation$Pause { + _CopyWithStubImpl$Variables$Mutation$Pause(this._res); + + TRes _res; + + call({ + String? orgSlug, + String? projectId, + }) => + _res; +} + +class Mutation$Pause { + Mutation$Pause({ + required this.pauseProject, + this.$__typename = 'Mutation', + }); + + factory Mutation$Pause.fromJson(Map json) { + final l$pauseProject = json['pauseProject']; + final l$$__typename = json['__typename']; + return Mutation$Pause( + pauseProject: Mutation$Pause$pauseProject.fromJson( + (l$pauseProject as Map)), + $__typename: (l$$__typename as String), + ); + } + + final Mutation$Pause$pauseProject pauseProject; + + final String $__typename; + + Map toJson() { + final _resultData = {}; + final l$pauseProject = pauseProject; + _resultData['pauseProject'] = l$pauseProject.toJson(); + final l$$__typename = $__typename; + _resultData['__typename'] = l$$__typename; + return _resultData; + } + + @override + int get hashCode { + final l$pauseProject = pauseProject; + final l$$__typename = $__typename; + return Object.hashAll([ + l$pauseProject, + l$$__typename, + ]); + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) { + return true; + } + if (!(other is Mutation$Pause) || runtimeType != other.runtimeType) { + return false; + } + final l$pauseProject = pauseProject; + final lOther$pauseProject = other.pauseProject; + if (l$pauseProject != lOther$pauseProject) { + return false; + } + final l$$__typename = $__typename; + final lOther$$__typename = other.$__typename; + if (l$$__typename != lOther$$__typename) { + return false; + } + return true; + } +} + +extension UtilityExtension$Mutation$Pause on Mutation$Pause { + CopyWith$Mutation$Pause get copyWith => + CopyWith$Mutation$Pause( + this, + (i) => i, + ); +} + +abstract class CopyWith$Mutation$Pause { + factory CopyWith$Mutation$Pause( + Mutation$Pause instance, + TRes Function(Mutation$Pause) then, + ) = _CopyWithImpl$Mutation$Pause; + + factory CopyWith$Mutation$Pause.stub(TRes res) = + _CopyWithStubImpl$Mutation$Pause; + + TRes call({ + Mutation$Pause$pauseProject? pauseProject, + String? $__typename, + }); + CopyWith$Mutation$Pause$pauseProject get pauseProject; +} + +class _CopyWithImpl$Mutation$Pause + implements CopyWith$Mutation$Pause { + _CopyWithImpl$Mutation$Pause( + this._instance, + this._then, + ); + + final Mutation$Pause _instance; + + final TRes Function(Mutation$Pause) _then; + + static const _undefined = {}; + + TRes call({ + Object? pauseProject = _undefined, + Object? $__typename = _undefined, + }) => + _then(Mutation$Pause( + pauseProject: pauseProject == _undefined || pauseProject == null + ? _instance.pauseProject + : (pauseProject as Mutation$Pause$pauseProject), + $__typename: $__typename == _undefined || $__typename == null + ? _instance.$__typename + : ($__typename as String), + )); + + CopyWith$Mutation$Pause$pauseProject get pauseProject { + final local$pauseProject = _instance.pauseProject; + return CopyWith$Mutation$Pause$pauseProject( + local$pauseProject, (e) => call(pauseProject: e)); + } +} + +class _CopyWithStubImpl$Mutation$Pause + implements CopyWith$Mutation$Pause { + _CopyWithStubImpl$Mutation$Pause(this._res); + + TRes _res; + + call({ + Mutation$Pause$pauseProject? pauseProject, + String? $__typename, + }) => + _res; + + CopyWith$Mutation$Pause$pauseProject get pauseProject => + CopyWith$Mutation$Pause$pauseProject.stub(_res); +} + +const documentNodeMutationPause = DocumentNode(definitions: [ + OperationDefinitionNode( + type: OperationType.mutation, + name: NameNode(value: 'Pause'), + variableDefinitions: [ + VariableDefinitionNode( + variable: VariableNode(name: NameNode(value: 'orgSlug')), + type: NamedTypeNode( + name: NameNode(value: 'String'), + isNonNull: true, + ), + defaultValue: DefaultValueNode(value: null), + directives: [], + ), + VariableDefinitionNode( + variable: VariableNode(name: NameNode(value: 'projectId')), + type: NamedTypeNode( + name: NameNode(value: 'String'), + isNonNull: true, + ), + defaultValue: DefaultValueNode(value: null), + directives: [], + ), + ], + directives: [], + selectionSet: SelectionSetNode(selections: [ + FieldNode( + name: NameNode(value: 'pauseProject'), + alias: null, + arguments: [ + ArgumentNode( + name: NameNode(value: 'orgSlug'), + value: VariableNode(name: NameNode(value: 'orgSlug')), + ), + ArgumentNode( + name: NameNode(value: 'projectId'), + value: VariableNode(name: NameNode(value: 'projectId')), + ), + ], + directives: [], + selectionSet: SelectionSetNode(selections: [ + FieldNode( + name: NameNode(value: 'message'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + FieldNode( + name: NameNode(value: '__typename'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + ]), + ), + FieldNode( + name: NameNode(value: '__typename'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + ]), + ), +]); +Mutation$Pause _parserFn$Mutation$Pause(Map data) => + Mutation$Pause.fromJson(data); +typedef OnMutationCompleted$Mutation$Pause = FutureOr Function( + Map?, + Mutation$Pause?, +); + +class Options$Mutation$Pause extends graphql.MutationOptions { + Options$Mutation$Pause({ + String? operationName, + required Variables$Mutation$Pause variables, + graphql.FetchPolicy? fetchPolicy, + graphql.ErrorPolicy? errorPolicy, + graphql.CacheRereadPolicy? cacheRereadPolicy, + Object? optimisticResult, + Mutation$Pause? typedOptimisticResult, + graphql.Context? context, + OnMutationCompleted$Mutation$Pause? onCompleted, + graphql.OnMutationUpdate? update, + graphql.OnError? onError, + }) : onCompletedWithParsed = onCompleted, + super( + variables: variables.toJson(), + operationName: operationName, + fetchPolicy: fetchPolicy, + errorPolicy: errorPolicy, + cacheRereadPolicy: cacheRereadPolicy, + optimisticResult: optimisticResult ?? typedOptimisticResult?.toJson(), + context: context, + onCompleted: onCompleted == null + ? null + : (data) => onCompleted( + data, + data == null ? null : _parserFn$Mutation$Pause(data), + ), + update: update, + onError: onError, + document: documentNodeMutationPause, + parserFn: _parserFn$Mutation$Pause, + ); + + final OnMutationCompleted$Mutation$Pause? onCompletedWithParsed; + + @override + List get properties => [ + ...super.onCompleted == null + ? super.properties + : super.properties.where((property) => property != onCompleted), + onCompletedWithParsed, + ]; +} + +class WatchOptions$Mutation$Pause + extends graphql.WatchQueryOptions { + WatchOptions$Mutation$Pause({ + String? operationName, + required Variables$Mutation$Pause variables, + graphql.FetchPolicy? fetchPolicy, + graphql.ErrorPolicy? errorPolicy, + graphql.CacheRereadPolicy? cacheRereadPolicy, + Object? optimisticResult, + Mutation$Pause? typedOptimisticResult, + graphql.Context? context, + Duration? pollInterval, + bool? eagerlyFetchResults, + bool carryForwardDataOnException = true, + bool fetchResults = false, + }) : super( + variables: variables.toJson(), + operationName: operationName, + fetchPolicy: fetchPolicy, + errorPolicy: errorPolicy, + cacheRereadPolicy: cacheRereadPolicy, + optimisticResult: optimisticResult ?? typedOptimisticResult?.toJson(), + context: context, + document: documentNodeMutationPause, + pollInterval: pollInterval, + eagerlyFetchResults: eagerlyFetchResults, + carryForwardDataOnException: carryForwardDataOnException, + fetchResults: fetchResults, + parserFn: _parserFn$Mutation$Pause, + ); +} + +extension ClientExtension$Mutation$Pause on graphql.GraphQLClient { + Future> mutate$Pause( + Options$Mutation$Pause options) async => + await this.mutate(options); + graphql.ObservableQuery watchMutation$Pause( + WatchOptions$Mutation$Pause options) => + this.watchMutation(options); +} + +class Mutation$Pause$pauseProject { + Mutation$Pause$pauseProject({ + required this.message, + this.$__typename = 'SuccessResponse', + }); + + factory Mutation$Pause$pauseProject.fromJson(Map json) { + final l$message = json['message']; + final l$$__typename = json['__typename']; + return Mutation$Pause$pauseProject( + message: (l$message as String), + $__typename: (l$$__typename as String), + ); + } + + final String message; + + final String $__typename; + + Map toJson() { + final _resultData = {}; + final l$message = message; + _resultData['message'] = l$message; + final l$$__typename = $__typename; + _resultData['__typename'] = l$$__typename; + return _resultData; + } + + @override + int get hashCode { + final l$message = message; + final l$$__typename = $__typename; + return Object.hashAll([ + l$message, + l$$__typename, + ]); + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) { + return true; + } + if (!(other is Mutation$Pause$pauseProject) || + runtimeType != other.runtimeType) { + return false; + } + final l$message = message; + final lOther$message = other.message; + if (l$message != lOther$message) { + return false; + } + final l$$__typename = $__typename; + final lOther$$__typename = other.$__typename; + if (l$$__typename != lOther$$__typename) { + return false; + } + return true; + } +} + +extension UtilityExtension$Mutation$Pause$pauseProject + on Mutation$Pause$pauseProject { + CopyWith$Mutation$Pause$pauseProject + get copyWith => CopyWith$Mutation$Pause$pauseProject( + this, + (i) => i, + ); +} + +abstract class CopyWith$Mutation$Pause$pauseProject { + factory CopyWith$Mutation$Pause$pauseProject( + Mutation$Pause$pauseProject instance, + TRes Function(Mutation$Pause$pauseProject) then, + ) = _CopyWithImpl$Mutation$Pause$pauseProject; + + factory CopyWith$Mutation$Pause$pauseProject.stub(TRes res) = + _CopyWithStubImpl$Mutation$Pause$pauseProject; + + TRes call({ + String? message, + String? $__typename, + }); +} + +class _CopyWithImpl$Mutation$Pause$pauseProject + implements CopyWith$Mutation$Pause$pauseProject { + _CopyWithImpl$Mutation$Pause$pauseProject( + this._instance, + this._then, + ); + + final Mutation$Pause$pauseProject _instance; + + final TRes Function(Mutation$Pause$pauseProject) _then; + + static const _undefined = {}; + + TRes call({ + Object? message = _undefined, + Object? $__typename = _undefined, + }) => + _then(Mutation$Pause$pauseProject( + message: message == _undefined || message == null + ? _instance.message + : (message as String), + $__typename: $__typename == _undefined || $__typename == null + ? _instance.$__typename + : ($__typename as String), + )); +} + +class _CopyWithStubImpl$Mutation$Pause$pauseProject + implements CopyWith$Mutation$Pause$pauseProject { + _CopyWithStubImpl$Mutation$Pause$pauseProject(this._res); + + TRes _res; + + call({ + String? message, + String? $__typename, + }) => + _res; +} + +class Variables$Mutation$Resume { + factory Variables$Mutation$Resume({ + required String orgSlug, + required String projectId, + }) => + Variables$Mutation$Resume._({ + r'orgSlug': orgSlug, + r'projectId': projectId, + }); + + Variables$Mutation$Resume._(this._$data); + + factory Variables$Mutation$Resume.fromJson(Map data) { + final result$data = {}; + final l$orgSlug = data['orgSlug']; + result$data['orgSlug'] = (l$orgSlug as String); + final l$projectId = data['projectId']; + result$data['projectId'] = (l$projectId as String); + return Variables$Mutation$Resume._(result$data); + } + + Map _$data; + + String get orgSlug => (_$data['orgSlug'] as String); + + String get projectId => (_$data['projectId'] as String); + + Map toJson() { + final result$data = {}; + final l$orgSlug = orgSlug; + result$data['orgSlug'] = l$orgSlug; + final l$projectId = projectId; + result$data['projectId'] = l$projectId; + return result$data; + } + + CopyWith$Variables$Mutation$Resume get copyWith => + CopyWith$Variables$Mutation$Resume( + this, + (i) => i, + ); + + @override + bool operator ==(Object other) { + if (identical(this, other)) { + return true; + } + if (!(other is Variables$Mutation$Resume) || + runtimeType != other.runtimeType) { + return false; + } + final l$orgSlug = orgSlug; + final lOther$orgSlug = other.orgSlug; + if (l$orgSlug != lOther$orgSlug) { + return false; + } + final l$projectId = projectId; + final lOther$projectId = other.projectId; + if (l$projectId != lOther$projectId) { + return false; + } + return true; + } + + @override + int get hashCode { + final l$orgSlug = orgSlug; + final l$projectId = projectId; + return Object.hashAll([ + l$orgSlug, + l$projectId, + ]); + } +} + +abstract class CopyWith$Variables$Mutation$Resume { + factory CopyWith$Variables$Mutation$Resume( + Variables$Mutation$Resume instance, + TRes Function(Variables$Mutation$Resume) then, + ) = _CopyWithImpl$Variables$Mutation$Resume; + + factory CopyWith$Variables$Mutation$Resume.stub(TRes res) = + _CopyWithStubImpl$Variables$Mutation$Resume; + + TRes call({ + String? orgSlug, + String? projectId, + }); +} + +class _CopyWithImpl$Variables$Mutation$Resume + implements CopyWith$Variables$Mutation$Resume { + _CopyWithImpl$Variables$Mutation$Resume( + this._instance, + this._then, + ); + + final Variables$Mutation$Resume _instance; + + final TRes Function(Variables$Mutation$Resume) _then; + + static const _undefined = {}; + + TRes call({ + Object? orgSlug = _undefined, + Object? projectId = _undefined, + }) => + _then(Variables$Mutation$Resume._({ + ..._instance._$data, + if (orgSlug != _undefined && orgSlug != null) + 'orgSlug': (orgSlug as String), + if (projectId != _undefined && projectId != null) + 'projectId': (projectId as String), + })); +} + +class _CopyWithStubImpl$Variables$Mutation$Resume + implements CopyWith$Variables$Mutation$Resume { + _CopyWithStubImpl$Variables$Mutation$Resume(this._res); + + TRes _res; + + call({ + String? orgSlug, + String? projectId, + }) => + _res; +} + +class Mutation$Resume { + Mutation$Resume({ + required this.resumeProject, + this.$__typename = 'Mutation', + }); + + factory Mutation$Resume.fromJson(Map json) { + final l$resumeProject = json['resumeProject']; + final l$$__typename = json['__typename']; + return Mutation$Resume( + resumeProject: Mutation$Resume$resumeProject.fromJson( + (l$resumeProject as Map)), + $__typename: (l$$__typename as String), + ); + } + + final Mutation$Resume$resumeProject resumeProject; + + final String $__typename; + + Map toJson() { + final _resultData = {}; + final l$resumeProject = resumeProject; + _resultData['resumeProject'] = l$resumeProject.toJson(); + final l$$__typename = $__typename; + _resultData['__typename'] = l$$__typename; + return _resultData; + } + + @override + int get hashCode { + final l$resumeProject = resumeProject; + final l$$__typename = $__typename; + return Object.hashAll([ + l$resumeProject, + l$$__typename, + ]); + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) { + return true; + } + if (!(other is Mutation$Resume) || runtimeType != other.runtimeType) { + return false; + } + final l$resumeProject = resumeProject; + final lOther$resumeProject = other.resumeProject; + if (l$resumeProject != lOther$resumeProject) { + return false; + } + final l$$__typename = $__typename; + final lOther$$__typename = other.$__typename; + if (l$$__typename != lOther$$__typename) { + return false; + } + return true; + } +} + +extension UtilityExtension$Mutation$Resume on Mutation$Resume { + CopyWith$Mutation$Resume get copyWith => + CopyWith$Mutation$Resume( + this, + (i) => i, + ); +} + +abstract class CopyWith$Mutation$Resume { + factory CopyWith$Mutation$Resume( + Mutation$Resume instance, + TRes Function(Mutation$Resume) then, + ) = _CopyWithImpl$Mutation$Resume; + + factory CopyWith$Mutation$Resume.stub(TRes res) = + _CopyWithStubImpl$Mutation$Resume; + + TRes call({ + Mutation$Resume$resumeProject? resumeProject, + String? $__typename, + }); + CopyWith$Mutation$Resume$resumeProject get resumeProject; +} + +class _CopyWithImpl$Mutation$Resume + implements CopyWith$Mutation$Resume { + _CopyWithImpl$Mutation$Resume( + this._instance, + this._then, + ); + + final Mutation$Resume _instance; + + final TRes Function(Mutation$Resume) _then; + + static const _undefined = {}; + + TRes call({ + Object? resumeProject = _undefined, + Object? $__typename = _undefined, + }) => + _then(Mutation$Resume( + resumeProject: resumeProject == _undefined || resumeProject == null + ? _instance.resumeProject + : (resumeProject as Mutation$Resume$resumeProject), + $__typename: $__typename == _undefined || $__typename == null + ? _instance.$__typename + : ($__typename as String), + )); + + CopyWith$Mutation$Resume$resumeProject get resumeProject { + final local$resumeProject = _instance.resumeProject; + return CopyWith$Mutation$Resume$resumeProject( + local$resumeProject, (e) => call(resumeProject: e)); + } +} + +class _CopyWithStubImpl$Mutation$Resume + implements CopyWith$Mutation$Resume { + _CopyWithStubImpl$Mutation$Resume(this._res); + + TRes _res; + + call({ + Mutation$Resume$resumeProject? resumeProject, + String? $__typename, + }) => + _res; + + CopyWith$Mutation$Resume$resumeProject get resumeProject => + CopyWith$Mutation$Resume$resumeProject.stub(_res); +} + +const documentNodeMutationResume = DocumentNode(definitions: [ + OperationDefinitionNode( + type: OperationType.mutation, + name: NameNode(value: 'Resume'), + variableDefinitions: [ + VariableDefinitionNode( + variable: VariableNode(name: NameNode(value: 'orgSlug')), + type: NamedTypeNode( + name: NameNode(value: 'String'), + isNonNull: true, + ), + defaultValue: DefaultValueNode(value: null), + directives: [], + ), + VariableDefinitionNode( + variable: VariableNode(name: NameNode(value: 'projectId')), + type: NamedTypeNode( + name: NameNode(value: 'String'), + isNonNull: true, + ), + defaultValue: DefaultValueNode(value: null), + directives: [], + ), + ], + directives: [], + selectionSet: SelectionSetNode(selections: [ + FieldNode( + name: NameNode(value: 'resumeProject'), + alias: null, + arguments: [ + ArgumentNode( + name: NameNode(value: 'orgSlug'), + value: VariableNode(name: NameNode(value: 'orgSlug')), + ), + ArgumentNode( + name: NameNode(value: 'projectId'), + value: VariableNode(name: NameNode(value: 'projectId')), + ), + ], + directives: [], + selectionSet: SelectionSetNode(selections: [ + FieldNode( + name: NameNode(value: 'message'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + FieldNode( + name: NameNode(value: '__typename'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + ]), + ), + FieldNode( + name: NameNode(value: '__typename'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + ]), + ), +]); +Mutation$Resume _parserFn$Mutation$Resume(Map data) => + Mutation$Resume.fromJson(data); +typedef OnMutationCompleted$Mutation$Resume = FutureOr Function( + Map?, + Mutation$Resume?, +); + +class Options$Mutation$Resume extends graphql.MutationOptions { + Options$Mutation$Resume({ + String? operationName, + required Variables$Mutation$Resume variables, + graphql.FetchPolicy? fetchPolicy, + graphql.ErrorPolicy? errorPolicy, + graphql.CacheRereadPolicy? cacheRereadPolicy, + Object? optimisticResult, + Mutation$Resume? typedOptimisticResult, + graphql.Context? context, + OnMutationCompleted$Mutation$Resume? onCompleted, + graphql.OnMutationUpdate? update, + graphql.OnError? onError, + }) : onCompletedWithParsed = onCompleted, + super( + variables: variables.toJson(), + operationName: operationName, + fetchPolicy: fetchPolicy, + errorPolicy: errorPolicy, + cacheRereadPolicy: cacheRereadPolicy, + optimisticResult: optimisticResult ?? typedOptimisticResult?.toJson(), + context: context, + onCompleted: onCompleted == null + ? null + : (data) => onCompleted( + data, + data == null ? null : _parserFn$Mutation$Resume(data), + ), + update: update, + onError: onError, + document: documentNodeMutationResume, + parserFn: _parserFn$Mutation$Resume, + ); + + final OnMutationCompleted$Mutation$Resume? onCompletedWithParsed; + + @override + List get properties => [ + ...super.onCompleted == null + ? super.properties + : super.properties.where((property) => property != onCompleted), + onCompletedWithParsed, + ]; +} + +class WatchOptions$Mutation$Resume + extends graphql.WatchQueryOptions { + WatchOptions$Mutation$Resume({ + String? operationName, + required Variables$Mutation$Resume variables, + graphql.FetchPolicy? fetchPolicy, + graphql.ErrorPolicy? errorPolicy, + graphql.CacheRereadPolicy? cacheRereadPolicy, + Object? optimisticResult, + Mutation$Resume? typedOptimisticResult, + graphql.Context? context, + Duration? pollInterval, + bool? eagerlyFetchResults, + bool carryForwardDataOnException = true, + bool fetchResults = false, + }) : super( + variables: variables.toJson(), + operationName: operationName, + fetchPolicy: fetchPolicy, + errorPolicy: errorPolicy, + cacheRereadPolicy: cacheRereadPolicy, + optimisticResult: optimisticResult ?? typedOptimisticResult?.toJson(), + context: context, + document: documentNodeMutationResume, + pollInterval: pollInterval, + eagerlyFetchResults: eagerlyFetchResults, + carryForwardDataOnException: carryForwardDataOnException, + fetchResults: fetchResults, + parserFn: _parserFn$Mutation$Resume, + ); +} + +extension ClientExtension$Mutation$Resume on graphql.GraphQLClient { + Future> mutate$Resume( + Options$Mutation$Resume options) async => + await this.mutate(options); + graphql.ObservableQuery watchMutation$Resume( + WatchOptions$Mutation$Resume options) => + this.watchMutation(options); +} + +class Mutation$Resume$resumeProject { + Mutation$Resume$resumeProject({ + required this.message, + this.$__typename = 'SuccessResponse', + }); + + factory Mutation$Resume$resumeProject.fromJson(Map json) { + final l$message = json['message']; + final l$$__typename = json['__typename']; + return Mutation$Resume$resumeProject( + message: (l$message as String), + $__typename: (l$$__typename as String), + ); + } + + final String message; + + final String $__typename; + + Map toJson() { + final _resultData = {}; + final l$message = message; + _resultData['message'] = l$message; + final l$$__typename = $__typename; + _resultData['__typename'] = l$$__typename; + return _resultData; + } + + @override + int get hashCode { + final l$message = message; + final l$$__typename = $__typename; + return Object.hashAll([ + l$message, + l$$__typename, + ]); + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) { + return true; + } + if (!(other is Mutation$Resume$resumeProject) || + runtimeType != other.runtimeType) { + return false; + } + final l$message = message; + final lOther$message = other.message; + if (l$message != lOther$message) { + return false; + } + final l$$__typename = $__typename; + final lOther$$__typename = other.$__typename; + if (l$$__typename != lOther$$__typename) { + return false; + } + return true; + } +} + +extension UtilityExtension$Mutation$Resume$resumeProject + on Mutation$Resume$resumeProject { + CopyWith$Mutation$Resume$resumeProject + get copyWith => CopyWith$Mutation$Resume$resumeProject( + this, + (i) => i, + ); +} + +abstract class CopyWith$Mutation$Resume$resumeProject { + factory CopyWith$Mutation$Resume$resumeProject( + Mutation$Resume$resumeProject instance, + TRes Function(Mutation$Resume$resumeProject) then, + ) = _CopyWithImpl$Mutation$Resume$resumeProject; + + factory CopyWith$Mutation$Resume$resumeProject.stub(TRes res) = + _CopyWithStubImpl$Mutation$Resume$resumeProject; + + TRes call({ + String? message, + String? $__typename, + }); +} + +class _CopyWithImpl$Mutation$Resume$resumeProject + implements CopyWith$Mutation$Resume$resumeProject { + _CopyWithImpl$Mutation$Resume$resumeProject( + this._instance, + this._then, + ); + + final Mutation$Resume$resumeProject _instance; + + final TRes Function(Mutation$Resume$resumeProject) _then; + + static const _undefined = {}; + + TRes call({ + Object? message = _undefined, + Object? $__typename = _undefined, + }) => + _then(Mutation$Resume$resumeProject( + message: message == _undefined || message == null + ? _instance.message + : (message as String), + $__typename: $__typename == _undefined || $__typename == null + ? _instance.$__typename + : ($__typename as String), + )); +} + +class _CopyWithStubImpl$Mutation$Resume$resumeProject + implements CopyWith$Mutation$Resume$resumeProject { + _CopyWithStubImpl$Mutation$Resume$resumeProject(this._res); + + TRes _res; + + call({ + String? message, + String? $__typename, + }) => + _res; +} + +class Variables$Mutation$CreateProject { + factory Variables$Mutation$CreateProject({ + required String orgSlug, + required String name, + }) => + Variables$Mutation$CreateProject._({ + r'orgSlug': orgSlug, + r'name': name, + }); + + Variables$Mutation$CreateProject._(this._$data); + + factory Variables$Mutation$CreateProject.fromJson(Map data) { + final result$data = {}; + final l$orgSlug = data['orgSlug']; + result$data['orgSlug'] = (l$orgSlug as String); + final l$name = data['name']; + result$data['name'] = (l$name as String); + return Variables$Mutation$CreateProject._(result$data); + } + + Map _$data; + + String get orgSlug => (_$data['orgSlug'] as String); + + String get name => (_$data['name'] as String); + + Map toJson() { + final result$data = {}; + final l$orgSlug = orgSlug; + result$data['orgSlug'] = l$orgSlug; + final l$name = name; + result$data['name'] = l$name; + return result$data; + } + + CopyWith$Variables$Mutation$CreateProject + get copyWith => CopyWith$Variables$Mutation$CreateProject( + this, + (i) => i, + ); + + @override + bool operator ==(Object other) { + if (identical(this, other)) { + return true; + } + if (!(other is Variables$Mutation$CreateProject) || + runtimeType != other.runtimeType) { + return false; + } + final l$orgSlug = orgSlug; + final lOther$orgSlug = other.orgSlug; + if (l$orgSlug != lOther$orgSlug) { + return false; + } + final l$name = name; + final lOther$name = other.name; + if (l$name != lOther$name) { + return false; + } + return true; + } + + @override + int get hashCode { + final l$orgSlug = orgSlug; + final l$name = name; + return Object.hashAll([ + l$orgSlug, + l$name, + ]); + } +} + +abstract class CopyWith$Variables$Mutation$CreateProject { + factory CopyWith$Variables$Mutation$CreateProject( + Variables$Mutation$CreateProject instance, + TRes Function(Variables$Mutation$CreateProject) then, + ) = _CopyWithImpl$Variables$Mutation$CreateProject; + + factory CopyWith$Variables$Mutation$CreateProject.stub(TRes res) = + _CopyWithStubImpl$Variables$Mutation$CreateProject; + + TRes call({ + String? orgSlug, + String? name, + }); +} + +class _CopyWithImpl$Variables$Mutation$CreateProject + implements CopyWith$Variables$Mutation$CreateProject { + _CopyWithImpl$Variables$Mutation$CreateProject( + this._instance, + this._then, + ); + + final Variables$Mutation$CreateProject _instance; + + final TRes Function(Variables$Mutation$CreateProject) _then; + + static const _undefined = {}; + + TRes call({ + Object? orgSlug = _undefined, + Object? name = _undefined, + }) => + _then(Variables$Mutation$CreateProject._({ + ..._instance._$data, + if (orgSlug != _undefined && orgSlug != null) + 'orgSlug': (orgSlug as String), + if (name != _undefined && name != null) 'name': (name as String), + })); +} + +class _CopyWithStubImpl$Variables$Mutation$CreateProject + implements CopyWith$Variables$Mutation$CreateProject { + _CopyWithStubImpl$Variables$Mutation$CreateProject(this._res); + + TRes _res; + + call({ + String? orgSlug, + String? name, + }) => + _res; +} + +class Mutation$CreateProject { + Mutation$CreateProject({ + required this.createProject, + this.$__typename = 'Mutation', + }); + + factory Mutation$CreateProject.fromJson(Map json) { + final l$createProject = json['createProject']; + final l$$__typename = json['__typename']; + return Mutation$CreateProject( + createProject: Mutation$CreateProject$createProject.fromJson( + (l$createProject as Map)), + $__typename: (l$$__typename as String), + ); + } + + final Mutation$CreateProject$createProject createProject; + + final String $__typename; + + Map toJson() { + final _resultData = {}; + final l$createProject = createProject; + _resultData['createProject'] = l$createProject.toJson(); + final l$$__typename = $__typename; + _resultData['__typename'] = l$$__typename; + return _resultData; + } + + @override + int get hashCode { + final l$createProject = createProject; + final l$$__typename = $__typename; + return Object.hashAll([ + l$createProject, + l$$__typename, + ]); + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) { + return true; + } + if (!(other is Mutation$CreateProject) || + runtimeType != other.runtimeType) { + return false; + } + final l$createProject = createProject; + final lOther$createProject = other.createProject; + if (l$createProject != lOther$createProject) { + return false; + } + final l$$__typename = $__typename; + final lOther$$__typename = other.$__typename; + if (l$$__typename != lOther$$__typename) { + return false; + } + return true; + } +} + +extension UtilityExtension$Mutation$CreateProject on Mutation$CreateProject { + CopyWith$Mutation$CreateProject get copyWith => + CopyWith$Mutation$CreateProject( + this, + (i) => i, + ); +} + +abstract class CopyWith$Mutation$CreateProject { + factory CopyWith$Mutation$CreateProject( + Mutation$CreateProject instance, + TRes Function(Mutation$CreateProject) then, + ) = _CopyWithImpl$Mutation$CreateProject; + + factory CopyWith$Mutation$CreateProject.stub(TRes res) = + _CopyWithStubImpl$Mutation$CreateProject; + + TRes call({ + Mutation$CreateProject$createProject? createProject, + String? $__typename, + }); + CopyWith$Mutation$CreateProject$createProject get createProject; +} + +class _CopyWithImpl$Mutation$CreateProject + implements CopyWith$Mutation$CreateProject { + _CopyWithImpl$Mutation$CreateProject( + this._instance, + this._then, + ); + + final Mutation$CreateProject _instance; + + final TRes Function(Mutation$CreateProject) _then; + + static const _undefined = {}; + + TRes call({ + Object? createProject = _undefined, + Object? $__typename = _undefined, + }) => + _then(Mutation$CreateProject( + createProject: createProject == _undefined || createProject == null + ? _instance.createProject + : (createProject as Mutation$CreateProject$createProject), + $__typename: $__typename == _undefined || $__typename == null + ? _instance.$__typename + : ($__typename as String), + )); + + CopyWith$Mutation$CreateProject$createProject get createProject { + final local$createProject = _instance.createProject; + return CopyWith$Mutation$CreateProject$createProject( + local$createProject, (e) => call(createProject: e)); + } +} + +class _CopyWithStubImpl$Mutation$CreateProject + implements CopyWith$Mutation$CreateProject { + _CopyWithStubImpl$Mutation$CreateProject(this._res); + + TRes _res; + + call({ + Mutation$CreateProject$createProject? createProject, + String? $__typename, + }) => + _res; + + CopyWith$Mutation$CreateProject$createProject get createProject => + CopyWith$Mutation$CreateProject$createProject.stub(_res); +} + +const documentNodeMutationCreateProject = DocumentNode(definitions: [ + OperationDefinitionNode( + type: OperationType.mutation, + name: NameNode(value: 'CreateProject'), + variableDefinitions: [ + VariableDefinitionNode( + variable: VariableNode(name: NameNode(value: 'orgSlug')), + type: NamedTypeNode( + name: NameNode(value: 'String'), + isNonNull: true, + ), + defaultValue: DefaultValueNode(value: null), + directives: [], + ), + VariableDefinitionNode( + variable: VariableNode(name: NameNode(value: 'name')), + type: NamedTypeNode( + name: NameNode(value: 'String'), + isNonNull: true, + ), + defaultValue: DefaultValueNode(value: null), + directives: [], + ), + ], + directives: [], + selectionSet: SelectionSetNode(selections: [ + FieldNode( + name: NameNode(value: 'createProject'), + alias: null, + arguments: [ + ArgumentNode( + name: NameNode(value: 'input'), + value: ObjectValueNode(fields: [ + ObjectFieldNode( + name: NameNode(value: 'slug'), + value: VariableNode(name: NameNode(value: 'name')), + ), + ObjectFieldNode( + name: NameNode(value: 'orgSlug'), + value: VariableNode(name: NameNode(value: 'orgSlug')), + ), + ]), + ) + ], + directives: [], + selectionSet: SelectionSetNode(selections: [ + FieldNode( + name: NameNode(value: 'id'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + FieldNode( + name: NameNode(value: 'slug'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + FieldNode( + name: NameNode(value: 'status'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + FieldNode( + name: NameNode(value: '__typename'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + ]), + ), + FieldNode( + name: NameNode(value: '__typename'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + ]), + ), +]); +Mutation$CreateProject _parserFn$Mutation$CreateProject( + Map data) => + Mutation$CreateProject.fromJson(data); +typedef OnMutationCompleted$Mutation$CreateProject = FutureOr Function( + Map?, + Mutation$CreateProject?, +); + +class Options$Mutation$CreateProject + extends graphql.MutationOptions { + Options$Mutation$CreateProject({ + String? operationName, + required Variables$Mutation$CreateProject variables, + graphql.FetchPolicy? fetchPolicy, + graphql.ErrorPolicy? errorPolicy, + graphql.CacheRereadPolicy? cacheRereadPolicy, + Object? optimisticResult, + Mutation$CreateProject? typedOptimisticResult, + graphql.Context? context, + OnMutationCompleted$Mutation$CreateProject? onCompleted, + graphql.OnMutationUpdate? update, + graphql.OnError? onError, + }) : onCompletedWithParsed = onCompleted, + super( + variables: variables.toJson(), + operationName: operationName, + fetchPolicy: fetchPolicy, + errorPolicy: errorPolicy, + cacheRereadPolicy: cacheRereadPolicy, + optimisticResult: optimisticResult ?? typedOptimisticResult?.toJson(), + context: context, + onCompleted: onCompleted == null + ? null + : (data) => onCompleted( + data, + data == null + ? null + : _parserFn$Mutation$CreateProject(data), + ), + update: update, + onError: onError, + document: documentNodeMutationCreateProject, + parserFn: _parserFn$Mutation$CreateProject, + ); + + final OnMutationCompleted$Mutation$CreateProject? onCompletedWithParsed; + + @override + List get properties => [ + ...super.onCompleted == null + ? super.properties + : super.properties.where((property) => property != onCompleted), + onCompletedWithParsed, + ]; +} + +class WatchOptions$Mutation$CreateProject + extends graphql.WatchQueryOptions { + WatchOptions$Mutation$CreateProject({ + String? operationName, + required Variables$Mutation$CreateProject variables, + graphql.FetchPolicy? fetchPolicy, + graphql.ErrorPolicy? errorPolicy, + graphql.CacheRereadPolicy? cacheRereadPolicy, + Object? optimisticResult, + Mutation$CreateProject? typedOptimisticResult, + graphql.Context? context, + Duration? pollInterval, + bool? eagerlyFetchResults, + bool carryForwardDataOnException = true, + bool fetchResults = false, + }) : super( + variables: variables.toJson(), + operationName: operationName, + fetchPolicy: fetchPolicy, + errorPolicy: errorPolicy, + cacheRereadPolicy: cacheRereadPolicy, + optimisticResult: optimisticResult ?? typedOptimisticResult?.toJson(), + context: context, + document: documentNodeMutationCreateProject, + pollInterval: pollInterval, + eagerlyFetchResults: eagerlyFetchResults, + carryForwardDataOnException: carryForwardDataOnException, + fetchResults: fetchResults, + parserFn: _parserFn$Mutation$CreateProject, + ); +} + +extension ClientExtension$Mutation$CreateProject on graphql.GraphQLClient { + Future> mutate$CreateProject( + Options$Mutation$CreateProject options) async => + await this.mutate(options); + graphql.ObservableQuery watchMutation$CreateProject( + WatchOptions$Mutation$CreateProject options) => + this.watchMutation(options); +} + +class Mutation$CreateProject$createProject { + Mutation$CreateProject$createProject({ + required this.id, + required this.slug, + required this.status, + this.$__typename = 'Project', + }); + + factory Mutation$CreateProject$createProject.fromJson( + Map json) { + final l$id = json['id']; + final l$slug = json['slug']; + final l$status = json['status']; + final l$$__typename = json['__typename']; + return Mutation$CreateProject$createProject( + id: (l$id as String), + slug: (l$slug as String), + status: fromJson$Enum$ProjectStatus((l$status as String)), + $__typename: (l$$__typename as String), + ); + } + + final String id; + + final String slug; + + final Enum$ProjectStatus status; + + final String $__typename; + + Map toJson() { + final _resultData = {}; + final l$id = id; + _resultData['id'] = l$id; + final l$slug = slug; + _resultData['slug'] = l$slug; + final l$status = status; + _resultData['status'] = toJson$Enum$ProjectStatus(l$status); + final l$$__typename = $__typename; + _resultData['__typename'] = l$$__typename; + return _resultData; + } + + @override + int get hashCode { + final l$id = id; + final l$slug = slug; + final l$status = status; + final l$$__typename = $__typename; + return Object.hashAll([ + l$id, + l$slug, + l$status, + l$$__typename, + ]); + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) { + return true; + } + if (!(other is Mutation$CreateProject$createProject) || + runtimeType != other.runtimeType) { + return false; + } + final l$id = id; + final lOther$id = other.id; + if (l$id != lOther$id) { + return false; + } + final l$slug = slug; + final lOther$slug = other.slug; + if (l$slug != lOther$slug) { + return false; + } + final l$status = status; + final lOther$status = other.status; + if (l$status != lOther$status) { + return false; + } + final l$$__typename = $__typename; + final lOther$$__typename = other.$__typename; + if (l$$__typename != lOther$$__typename) { + return false; + } + return true; + } +} + +extension UtilityExtension$Mutation$CreateProject$createProject + on Mutation$CreateProject$createProject { + CopyWith$Mutation$CreateProject$createProject< + Mutation$CreateProject$createProject> + get copyWith => CopyWith$Mutation$CreateProject$createProject( + this, + (i) => i, + ); +} + +abstract class CopyWith$Mutation$CreateProject$createProject { + factory CopyWith$Mutation$CreateProject$createProject( + Mutation$CreateProject$createProject instance, + TRes Function(Mutation$CreateProject$createProject) then, + ) = _CopyWithImpl$Mutation$CreateProject$createProject; + + factory CopyWith$Mutation$CreateProject$createProject.stub(TRes res) = + _CopyWithStubImpl$Mutation$CreateProject$createProject; + + TRes call({ + String? id, + String? slug, + Enum$ProjectStatus? status, + String? $__typename, + }); +} + +class _CopyWithImpl$Mutation$CreateProject$createProject + implements CopyWith$Mutation$CreateProject$createProject { + _CopyWithImpl$Mutation$CreateProject$createProject( + this._instance, + this._then, + ); + + final Mutation$CreateProject$createProject _instance; + + final TRes Function(Mutation$CreateProject$createProject) _then; + + static const _undefined = {}; + + TRes call({ + Object? id = _undefined, + Object? slug = _undefined, + Object? status = _undefined, + Object? $__typename = _undefined, + }) => + _then(Mutation$CreateProject$createProject( + id: id == _undefined || id == null ? _instance.id : (id as String), + slug: slug == _undefined || slug == null + ? _instance.slug + : (slug as String), + status: status == _undefined || status == null + ? _instance.status + : (status as Enum$ProjectStatus), + $__typename: $__typename == _undefined || $__typename == null + ? _instance.$__typename + : ($__typename as String), + )); +} + +class _CopyWithStubImpl$Mutation$CreateProject$createProject + implements CopyWith$Mutation$CreateProject$createProject { + _CopyWithStubImpl$Mutation$CreateProject$createProject(this._res); + + TRes _res; + + call({ + String? id, + String? slug, + Enum$ProjectStatus? status, + String? $__typename, + }) => + _res; +} + +class Variables$Query$Projects { + factory Variables$Query$Projects({required String orgSlug}) => + Variables$Query$Projects._({ + r'orgSlug': orgSlug, + }); + + Variables$Query$Projects._(this._$data); + + factory Variables$Query$Projects.fromJson(Map data) { + final result$data = {}; + final l$orgSlug = data['orgSlug']; + result$data['orgSlug'] = (l$orgSlug as String); + return Variables$Query$Projects._(result$data); + } + + Map _$data; + + String get orgSlug => (_$data['orgSlug'] as String); + + Map toJson() { + final result$data = {}; + final l$orgSlug = orgSlug; + result$data['orgSlug'] = l$orgSlug; + return result$data; + } + + CopyWith$Variables$Query$Projects get copyWith => + CopyWith$Variables$Query$Projects( + this, + (i) => i, + ); + + @override + bool operator ==(Object other) { + if (identical(this, other)) { + return true; + } + if (!(other is Variables$Query$Projects) || + runtimeType != other.runtimeType) { + return false; + } + final l$orgSlug = orgSlug; + final lOther$orgSlug = other.orgSlug; + if (l$orgSlug != lOther$orgSlug) { + return false; + } + return true; + } + + @override + int get hashCode { + final l$orgSlug = orgSlug; + return Object.hashAll([l$orgSlug]); + } +} + +abstract class CopyWith$Variables$Query$Projects { + factory CopyWith$Variables$Query$Projects( + Variables$Query$Projects instance, + TRes Function(Variables$Query$Projects) then, + ) = _CopyWithImpl$Variables$Query$Projects; + + factory CopyWith$Variables$Query$Projects.stub(TRes res) = + _CopyWithStubImpl$Variables$Query$Projects; + + TRes call({String? orgSlug}); +} + +class _CopyWithImpl$Variables$Query$Projects + implements CopyWith$Variables$Query$Projects { + _CopyWithImpl$Variables$Query$Projects( + this._instance, + this._then, + ); + + final Variables$Query$Projects _instance; + + final TRes Function(Variables$Query$Projects) _then; + + static const _undefined = {}; + + TRes call({Object? orgSlug = _undefined}) => + _then(Variables$Query$Projects._({ + ..._instance._$data, + if (orgSlug != _undefined && orgSlug != null) + 'orgSlug': (orgSlug as String), + })); +} + +class _CopyWithStubImpl$Variables$Query$Projects + implements CopyWith$Variables$Query$Projects { + _CopyWithStubImpl$Variables$Query$Projects(this._res); + + TRes _res; + + call({String? orgSlug}) => _res; +} + +class Query$Projects { + Query$Projects({ + required this.projects, + this.$__typename = 'Query', + }); + + factory Query$Projects.fromJson(Map json) { + final l$projects = json['projects']; + final l$$__typename = json['__typename']; + return Query$Projects( + projects: (l$projects as List) + .map((e) => + Query$Projects$projects.fromJson((e as Map))) + .toList(), + $__typename: (l$$__typename as String), + ); + } + + final List projects; + + final String $__typename; + + Map toJson() { + final _resultData = {}; + final l$projects = projects; + _resultData['projects'] = l$projects.map((e) => e.toJson()).toList(); + final l$$__typename = $__typename; + _resultData['__typename'] = l$$__typename; + return _resultData; + } + + @override + int get hashCode { + final l$projects = projects; + final l$$__typename = $__typename; + return Object.hashAll([ + Object.hashAll(l$projects.map((v) => v)), + l$$__typename, + ]); + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) { + return true; + } + if (!(other is Query$Projects) || runtimeType != other.runtimeType) { + return false; + } + final l$projects = projects; + final lOther$projects = other.projects; + if (l$projects.length != lOther$projects.length) { + return false; + } + for (int i = 0; i < l$projects.length; i++) { + final l$projects$entry = l$projects[i]; + final lOther$projects$entry = lOther$projects[i]; + if (l$projects$entry != lOther$projects$entry) { + return false; + } + } + final l$$__typename = $__typename; + final lOther$$__typename = other.$__typename; + if (l$$__typename != lOther$$__typename) { + return false; + } + return true; + } +} + +extension UtilityExtension$Query$Projects on Query$Projects { + CopyWith$Query$Projects get copyWith => + CopyWith$Query$Projects( + this, + (i) => i, + ); +} + +abstract class CopyWith$Query$Projects { + factory CopyWith$Query$Projects( + Query$Projects instance, + TRes Function(Query$Projects) then, + ) = _CopyWithImpl$Query$Projects; + + factory CopyWith$Query$Projects.stub(TRes res) = + _CopyWithStubImpl$Query$Projects; + + TRes call({ + List? projects, + String? $__typename, + }); + TRes projects( + Iterable Function( + Iterable< + CopyWith$Query$Projects$projects>) + _fn); +} + +class _CopyWithImpl$Query$Projects + implements CopyWith$Query$Projects { + _CopyWithImpl$Query$Projects( + this._instance, + this._then, + ); + + final Query$Projects _instance; + + final TRes Function(Query$Projects) _then; + + static const _undefined = {}; + + TRes call({ + Object? projects = _undefined, + Object? $__typename = _undefined, + }) => + _then(Query$Projects( + projects: projects == _undefined || projects == null + ? _instance.projects + : (projects as List), + $__typename: $__typename == _undefined || $__typename == null + ? _instance.$__typename + : ($__typename as String), + )); + + TRes projects( + Iterable Function( + Iterable< + CopyWith$Query$Projects$projects< + Query$Projects$projects>>) + _fn) => + call( + projects: _fn( + _instance.projects.map((e) => CopyWith$Query$Projects$projects( + e, + (i) => i, + ))).toList()); +} + +class _CopyWithStubImpl$Query$Projects + implements CopyWith$Query$Projects { + _CopyWithStubImpl$Query$Projects(this._res); + + TRes _res; + + call({ + List? projects, + String? $__typename, + }) => + _res; + + projects(_fn) => _res; +} + +const documentNodeQueryProjects = DocumentNode(definitions: [ + OperationDefinitionNode( + type: OperationType.query, + name: NameNode(value: 'Projects'), + variableDefinitions: [ + VariableDefinitionNode( + variable: VariableNode(name: NameNode(value: 'orgSlug')), + type: NamedTypeNode( + name: NameNode(value: 'String'), + isNonNull: true, + ), + defaultValue: DefaultValueNode(value: null), + directives: [], + ) + ], + directives: [], + selectionSet: SelectionSetNode(selections: [ + FieldNode( + name: NameNode(value: 'projects'), + alias: null, + arguments: [ + ArgumentNode( + name: NameNode(value: 'orgSlug'), + value: VariableNode(name: NameNode(value: 'orgSlug')), + ) + ], + directives: [], + selectionSet: SelectionSetNode(selections: [ + FieldNode( + name: NameNode(value: 'id'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + FieldNode( + name: NameNode(value: 'slug'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + FieldNode( + name: NameNode(value: 'status'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + FieldNode( + name: NameNode(value: '__typename'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + ]), + ), + FieldNode( + name: NameNode(value: '__typename'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + ]), + ), +]); +Query$Projects _parserFn$Query$Projects(Map data) => + Query$Projects.fromJson(data); +typedef OnQueryComplete$Query$Projects = FutureOr Function( + Map?, + Query$Projects?, +); + +class Options$Query$Projects extends graphql.QueryOptions { + Options$Query$Projects({ + String? operationName, + required Variables$Query$Projects variables, + graphql.FetchPolicy? fetchPolicy, + graphql.ErrorPolicy? errorPolicy, + graphql.CacheRereadPolicy? cacheRereadPolicy, + Object? optimisticResult, + Query$Projects? typedOptimisticResult, + Duration? pollInterval, + graphql.Context? context, + OnQueryComplete$Query$Projects? onComplete, + graphql.OnQueryError? onError, + }) : onCompleteWithParsed = onComplete, + super( + variables: variables.toJson(), + operationName: operationName, + fetchPolicy: fetchPolicy, + errorPolicy: errorPolicy, + cacheRereadPolicy: cacheRereadPolicy, + optimisticResult: optimisticResult ?? typedOptimisticResult?.toJson(), + pollInterval: pollInterval, + context: context, + onComplete: onComplete == null + ? null + : (data) => onComplete( + data, + data == null ? null : _parserFn$Query$Projects(data), + ), + onError: onError, + document: documentNodeQueryProjects, + parserFn: _parserFn$Query$Projects, + ); + + final OnQueryComplete$Query$Projects? onCompleteWithParsed; + + @override + List get properties => [ + ...super.onComplete == null + ? super.properties + : super.properties.where((property) => property != onComplete), + onCompleteWithParsed, + ]; +} + +class WatchOptions$Query$Projects + extends graphql.WatchQueryOptions { + WatchOptions$Query$Projects({ + String? operationName, + required Variables$Query$Projects variables, + graphql.FetchPolicy? fetchPolicy, + graphql.ErrorPolicy? errorPolicy, + graphql.CacheRereadPolicy? cacheRereadPolicy, + Object? optimisticResult, + Query$Projects? typedOptimisticResult, + graphql.Context? context, + Duration? pollInterval, + bool? eagerlyFetchResults, + bool carryForwardDataOnException = true, + bool fetchResults = false, + }) : super( + variables: variables.toJson(), + operationName: operationName, + fetchPolicy: fetchPolicy, + errorPolicy: errorPolicy, + cacheRereadPolicy: cacheRereadPolicy, + optimisticResult: optimisticResult ?? typedOptimisticResult?.toJson(), + context: context, + document: documentNodeQueryProjects, + pollInterval: pollInterval, + eagerlyFetchResults: eagerlyFetchResults, + carryForwardDataOnException: carryForwardDataOnException, + fetchResults: fetchResults, + parserFn: _parserFn$Query$Projects, + ); +} + +class FetchMoreOptions$Query$Projects extends graphql.FetchMoreOptions { + FetchMoreOptions$Query$Projects({ + required graphql.UpdateQuery updateQuery, + required Variables$Query$Projects variables, + }) : super( + updateQuery: updateQuery, + variables: variables.toJson(), + document: documentNodeQueryProjects, + ); +} + +extension ClientExtension$Query$Projects on graphql.GraphQLClient { + Future> query$Projects( + Options$Query$Projects options) async => + await this.query(options); + graphql.ObservableQuery watchQuery$Projects( + WatchOptions$Query$Projects options) => + this.watchQuery(options); + void writeQuery$Projects({ + required Query$Projects data, + required Variables$Query$Projects variables, + bool broadcast = true, + }) => + this.writeQuery( + graphql.Request( + operation: graphql.Operation(document: documentNodeQueryProjects), + variables: variables.toJson(), + ), + data: data.toJson(), + broadcast: broadcast, + ); + Query$Projects? readQuery$Projects({ + required Variables$Query$Projects variables, + bool optimistic = true, + }) { + final result = this.readQuery( + graphql.Request( + operation: graphql.Operation(document: documentNodeQueryProjects), + variables: variables.toJson(), + ), + optimistic: optimistic, + ); + return result == null ? null : Query$Projects.fromJson(result); + } +} + +class Query$Projects$projects { + Query$Projects$projects({ + required this.id, + required this.slug, + required this.status, + this.$__typename = 'Project', + }); + + factory Query$Projects$projects.fromJson(Map json) { + final l$id = json['id']; + final l$slug = json['slug']; + final l$status = json['status']; + final l$$__typename = json['__typename']; + return Query$Projects$projects( + id: (l$id as String), + slug: (l$slug as String), + status: fromJson$Enum$ProjectStatus((l$status as String)), + $__typename: (l$$__typename as String), + ); + } + + final String id; + + final String slug; + + final Enum$ProjectStatus status; + + final String $__typename; + + Map toJson() { + final _resultData = {}; + final l$id = id; + _resultData['id'] = l$id; + final l$slug = slug; + _resultData['slug'] = l$slug; + final l$status = status; + _resultData['status'] = toJson$Enum$ProjectStatus(l$status); + final l$$__typename = $__typename; + _resultData['__typename'] = l$$__typename; + return _resultData; + } + + @override + int get hashCode { + final l$id = id; + final l$slug = slug; + final l$status = status; + final l$$__typename = $__typename; + return Object.hashAll([ + l$id, + l$slug, + l$status, + l$$__typename, + ]); + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) { + return true; + } + if (!(other is Query$Projects$projects) || + runtimeType != other.runtimeType) { + return false; + } + final l$id = id; + final lOther$id = other.id; + if (l$id != lOther$id) { + return false; + } + final l$slug = slug; + final lOther$slug = other.slug; + if (l$slug != lOther$slug) { + return false; + } + final l$status = status; + final lOther$status = other.status; + if (l$status != lOther$status) { + return false; + } + final l$$__typename = $__typename; + final lOther$$__typename = other.$__typename; + if (l$$__typename != lOther$$__typename) { + return false; + } + return true; + } +} + +extension UtilityExtension$Query$Projects$projects on Query$Projects$projects { + CopyWith$Query$Projects$projects get copyWith => + CopyWith$Query$Projects$projects( + this, + (i) => i, + ); +} + +abstract class CopyWith$Query$Projects$projects { + factory CopyWith$Query$Projects$projects( + Query$Projects$projects instance, + TRes Function(Query$Projects$projects) then, + ) = _CopyWithImpl$Query$Projects$projects; + + factory CopyWith$Query$Projects$projects.stub(TRes res) = + _CopyWithStubImpl$Query$Projects$projects; + + TRes call({ + String? id, + String? slug, + Enum$ProjectStatus? status, + String? $__typename, + }); +} + +class _CopyWithImpl$Query$Projects$projects + implements CopyWith$Query$Projects$projects { + _CopyWithImpl$Query$Projects$projects( + this._instance, + this._then, + ); + + final Query$Projects$projects _instance; + + final TRes Function(Query$Projects$projects) _then; + + static const _undefined = {}; + + TRes call({ + Object? id = _undefined, + Object? slug = _undefined, + Object? status = _undefined, + Object? $__typename = _undefined, + }) => + _then(Query$Projects$projects( + id: id == _undefined || id == null ? _instance.id : (id as String), + slug: slug == _undefined || slug == null + ? _instance.slug + : (slug as String), + status: status == _undefined || status == null + ? _instance.status + : (status as Enum$ProjectStatus), + $__typename: $__typename == _undefined || $__typename == null + ? _instance.$__typename + : ($__typename as String), + )); +} + +class _CopyWithStubImpl$Query$Projects$projects + implements CopyWith$Query$Projects$projects { + _CopyWithStubImpl$Query$Projects$projects(this._res); + + TRes _res; + + call({ + String? id, + String? slug, + Enum$ProjectStatus? status, + String? $__typename, + }) => + _res; +} diff --git a/packages/globe_cli/lib/src/commands/project/project_pause_command.dart b/packages/globe_cli/lib/src/commands/project/project_pause_command.dart index 6d19217..edb3cc7 100644 --- a/packages/globe_cli/lib/src/commands/project/project_pause_command.dart +++ b/packages/globe_cli/lib/src/commands/project/project_pause_command.dart @@ -24,13 +24,14 @@ class ProjectPauseCommand extends BaseGlobeCommand { final validated = await _validator(); final projectSlug = validated.project.slug; - final pauseProjectProgress = - logger.progress('Pausing project: ${cyan.wrap(projectSlug)}'); + final pauseProjectProgress = logger.progress( + 'Pausing project: ${cyan.wrap(projectSlug)}', + ); try { await api.pauseProject( - orgId: validated.organization.id, - projectId: validated.project.id, + orgSlug: validated.organization.slug, + projectSlug: validated.project.slug, ); pauseProjectProgress diff --git a/packages/globe_cli/lib/src/commands/project/project_resume_command.dart b/packages/globe_cli/lib/src/commands/project/project_resume_command.dart index 9f2053b..e120570 100644 --- a/packages/globe_cli/lib/src/commands/project/project_resume_command.dart +++ b/packages/globe_cli/lib/src/commands/project/project_resume_command.dart @@ -29,8 +29,8 @@ class ProjectResumeCommand extends BaseGlobeCommand { try { await api.resumeProject( - orgId: validated.organization.id, - projectId: validated.project.id, + orgSlug: validated.organization.slug, + projectSlug: validated.project.slug, ); pauseProjectProgress diff --git a/packages/globe_cli/lib/src/commands/token/token.graphql b/packages/globe_cli/lib/src/commands/token/token.graphql new file mode 100644 index 0000000..9cb9bc7 --- /dev/null +++ b/packages/globe_cli/lib/src/commands/token/token.graphql @@ -0,0 +1,30 @@ +mutation CreateToken( + $orgSlug: String! + $name: String! + $expiresAt: DateTime! + $projects: [String!]! +) { + createToken( + orgSlug: $orgSlug + name: $name + expiresAt: $expiresAt + projects: $projects + ) { + uuid + value + } +} + +mutation DeleteToken($orgSlug: String!, $tokenUuid: String!) { + deleteToken(uuid: $tokenUuid, orgSlug: $orgSlug) { + message + } +} + +query ListTokens($orgSlug: String!, $projects: [String!]!) { + tokens(orgSlug: $orgSlug, projects: $projects) { + uuid + name + expiresAt + } +} diff --git a/packages/globe_cli/lib/src/commands/token/token.graphql.dart b/packages/globe_cli/lib/src/commands/token/token.graphql.dart new file mode 100644 index 0000000..d5c5221 --- /dev/null +++ b/packages/globe_cli/lib/src/commands/token/token.graphql.dart @@ -0,0 +1,1875 @@ +// ignore_for_file: type=lint +import 'dart:async'; +import 'package:gql/ast.dart'; +import 'package:graphql/client.dart' as graphql; + +class Variables$Mutation$CreateToken { + factory Variables$Mutation$CreateToken({ + required String orgSlug, + required String name, + required String expiresAt, + required List projects, + }) => + Variables$Mutation$CreateToken._({ + r'orgSlug': orgSlug, + r'name': name, + r'expiresAt': expiresAt, + r'projects': projects, + }); + + Variables$Mutation$CreateToken._(this._$data); + + factory Variables$Mutation$CreateToken.fromJson(Map data) { + final result$data = {}; + final l$orgSlug = data['orgSlug']; + result$data['orgSlug'] = (l$orgSlug as String); + final l$name = data['name']; + result$data['name'] = (l$name as String); + final l$expiresAt = data['expiresAt']; + result$data['expiresAt'] = (l$expiresAt as String); + final l$projects = data['projects']; + result$data['projects'] = + (l$projects as List).map((e) => (e as String)).toList(); + return Variables$Mutation$CreateToken._(result$data); + } + + Map _$data; + + String get orgSlug => (_$data['orgSlug'] as String); + + String get name => (_$data['name'] as String); + + String get expiresAt => (_$data['expiresAt'] as String); + + List get projects => (_$data['projects'] as List); + + Map toJson() { + final result$data = {}; + final l$orgSlug = orgSlug; + result$data['orgSlug'] = l$orgSlug; + final l$name = name; + result$data['name'] = l$name; + final l$expiresAt = expiresAt; + result$data['expiresAt'] = l$expiresAt; + final l$projects = projects; + result$data['projects'] = l$projects.map((e) => e).toList(); + return result$data; + } + + CopyWith$Variables$Mutation$CreateToken + get copyWith => CopyWith$Variables$Mutation$CreateToken( + this, + (i) => i, + ); + + @override + bool operator ==(Object other) { + if (identical(this, other)) { + return true; + } + if (!(other is Variables$Mutation$CreateToken) || + runtimeType != other.runtimeType) { + return false; + } + final l$orgSlug = orgSlug; + final lOther$orgSlug = other.orgSlug; + if (l$orgSlug != lOther$orgSlug) { + return false; + } + final l$name = name; + final lOther$name = other.name; + if (l$name != lOther$name) { + return false; + } + final l$expiresAt = expiresAt; + final lOther$expiresAt = other.expiresAt; + if (l$expiresAt != lOther$expiresAt) { + return false; + } + final l$projects = projects; + final lOther$projects = other.projects; + if (l$projects.length != lOther$projects.length) { + return false; + } + for (int i = 0; i < l$projects.length; i++) { + final l$projects$entry = l$projects[i]; + final lOther$projects$entry = lOther$projects[i]; + if (l$projects$entry != lOther$projects$entry) { + return false; + } + } + return true; + } + + @override + int get hashCode { + final l$orgSlug = orgSlug; + final l$name = name; + final l$expiresAt = expiresAt; + final l$projects = projects; + return Object.hashAll([ + l$orgSlug, + l$name, + l$expiresAt, + Object.hashAll(l$projects.map((v) => v)), + ]); + } +} + +abstract class CopyWith$Variables$Mutation$CreateToken { + factory CopyWith$Variables$Mutation$CreateToken( + Variables$Mutation$CreateToken instance, + TRes Function(Variables$Mutation$CreateToken) then, + ) = _CopyWithImpl$Variables$Mutation$CreateToken; + + factory CopyWith$Variables$Mutation$CreateToken.stub(TRes res) = + _CopyWithStubImpl$Variables$Mutation$CreateToken; + + TRes call({ + String? orgSlug, + String? name, + String? expiresAt, + List? projects, + }); +} + +class _CopyWithImpl$Variables$Mutation$CreateToken + implements CopyWith$Variables$Mutation$CreateToken { + _CopyWithImpl$Variables$Mutation$CreateToken( + this._instance, + this._then, + ); + + final Variables$Mutation$CreateToken _instance; + + final TRes Function(Variables$Mutation$CreateToken) _then; + + static const _undefined = {}; + + TRes call({ + Object? orgSlug = _undefined, + Object? name = _undefined, + Object? expiresAt = _undefined, + Object? projects = _undefined, + }) => + _then(Variables$Mutation$CreateToken._({ + ..._instance._$data, + if (orgSlug != _undefined && orgSlug != null) + 'orgSlug': (orgSlug as String), + if (name != _undefined && name != null) 'name': (name as String), + if (expiresAt != _undefined && expiresAt != null) + 'expiresAt': (expiresAt as String), + if (projects != _undefined && projects != null) + 'projects': (projects as List), + })); +} + +class _CopyWithStubImpl$Variables$Mutation$CreateToken + implements CopyWith$Variables$Mutation$CreateToken { + _CopyWithStubImpl$Variables$Mutation$CreateToken(this._res); + + TRes _res; + + call({ + String? orgSlug, + String? name, + String? expiresAt, + List? projects, + }) => + _res; +} + +class Mutation$CreateToken { + Mutation$CreateToken({ + required this.createToken, + this.$__typename = 'Mutation', + }); + + factory Mutation$CreateToken.fromJson(Map json) { + final l$createToken = json['createToken']; + final l$$__typename = json['__typename']; + return Mutation$CreateToken( + createToken: Mutation$CreateToken$createToken.fromJson( + (l$createToken as Map)), + $__typename: (l$$__typename as String), + ); + } + + final Mutation$CreateToken$createToken createToken; + + final String $__typename; + + Map toJson() { + final _resultData = {}; + final l$createToken = createToken; + _resultData['createToken'] = l$createToken.toJson(); + final l$$__typename = $__typename; + _resultData['__typename'] = l$$__typename; + return _resultData; + } + + @override + int get hashCode { + final l$createToken = createToken; + final l$$__typename = $__typename; + return Object.hashAll([ + l$createToken, + l$$__typename, + ]); + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) { + return true; + } + if (!(other is Mutation$CreateToken) || runtimeType != other.runtimeType) { + return false; + } + final l$createToken = createToken; + final lOther$createToken = other.createToken; + if (l$createToken != lOther$createToken) { + return false; + } + final l$$__typename = $__typename; + final lOther$$__typename = other.$__typename; + if (l$$__typename != lOther$$__typename) { + return false; + } + return true; + } +} + +extension UtilityExtension$Mutation$CreateToken on Mutation$CreateToken { + CopyWith$Mutation$CreateToken get copyWith => + CopyWith$Mutation$CreateToken( + this, + (i) => i, + ); +} + +abstract class CopyWith$Mutation$CreateToken { + factory CopyWith$Mutation$CreateToken( + Mutation$CreateToken instance, + TRes Function(Mutation$CreateToken) then, + ) = _CopyWithImpl$Mutation$CreateToken; + + factory CopyWith$Mutation$CreateToken.stub(TRes res) = + _CopyWithStubImpl$Mutation$CreateToken; + + TRes call({ + Mutation$CreateToken$createToken? createToken, + String? $__typename, + }); + CopyWith$Mutation$CreateToken$createToken get createToken; +} + +class _CopyWithImpl$Mutation$CreateToken + implements CopyWith$Mutation$CreateToken { + _CopyWithImpl$Mutation$CreateToken( + this._instance, + this._then, + ); + + final Mutation$CreateToken _instance; + + final TRes Function(Mutation$CreateToken) _then; + + static const _undefined = {}; + + TRes call({ + Object? createToken = _undefined, + Object? $__typename = _undefined, + }) => + _then(Mutation$CreateToken( + createToken: createToken == _undefined || createToken == null + ? _instance.createToken + : (createToken as Mutation$CreateToken$createToken), + $__typename: $__typename == _undefined || $__typename == null + ? _instance.$__typename + : ($__typename as String), + )); + + CopyWith$Mutation$CreateToken$createToken get createToken { + final local$createToken = _instance.createToken; + return CopyWith$Mutation$CreateToken$createToken( + local$createToken, (e) => call(createToken: e)); + } +} + +class _CopyWithStubImpl$Mutation$CreateToken + implements CopyWith$Mutation$CreateToken { + _CopyWithStubImpl$Mutation$CreateToken(this._res); + + TRes _res; + + call({ + Mutation$CreateToken$createToken? createToken, + String? $__typename, + }) => + _res; + + CopyWith$Mutation$CreateToken$createToken get createToken => + CopyWith$Mutation$CreateToken$createToken.stub(_res); +} + +const documentNodeMutationCreateToken = DocumentNode(definitions: [ + OperationDefinitionNode( + type: OperationType.mutation, + name: NameNode(value: 'CreateToken'), + variableDefinitions: [ + VariableDefinitionNode( + variable: VariableNode(name: NameNode(value: 'orgSlug')), + type: NamedTypeNode( + name: NameNode(value: 'String'), + isNonNull: true, + ), + defaultValue: DefaultValueNode(value: null), + directives: [], + ), + VariableDefinitionNode( + variable: VariableNode(name: NameNode(value: 'name')), + type: NamedTypeNode( + name: NameNode(value: 'String'), + isNonNull: true, + ), + defaultValue: DefaultValueNode(value: null), + directives: [], + ), + VariableDefinitionNode( + variable: VariableNode(name: NameNode(value: 'expiresAt')), + type: NamedTypeNode( + name: NameNode(value: 'DateTime'), + isNonNull: true, + ), + defaultValue: DefaultValueNode(value: null), + directives: [], + ), + VariableDefinitionNode( + variable: VariableNode(name: NameNode(value: 'projects')), + type: ListTypeNode( + type: NamedTypeNode( + name: NameNode(value: 'String'), + isNonNull: true, + ), + isNonNull: true, + ), + defaultValue: DefaultValueNode(value: null), + directives: [], + ), + ], + directives: [], + selectionSet: SelectionSetNode(selections: [ + FieldNode( + name: NameNode(value: 'createToken'), + alias: null, + arguments: [ + ArgumentNode( + name: NameNode(value: 'orgSlug'), + value: VariableNode(name: NameNode(value: 'orgSlug')), + ), + ArgumentNode( + name: NameNode(value: 'name'), + value: VariableNode(name: NameNode(value: 'name')), + ), + ArgumentNode( + name: NameNode(value: 'expiresAt'), + value: VariableNode(name: NameNode(value: 'expiresAt')), + ), + ArgumentNode( + name: NameNode(value: 'projects'), + value: VariableNode(name: NameNode(value: 'projects')), + ), + ], + directives: [], + selectionSet: SelectionSetNode(selections: [ + FieldNode( + name: NameNode(value: 'uuid'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + FieldNode( + name: NameNode(value: 'value'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + FieldNode( + name: NameNode(value: '__typename'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + ]), + ), + FieldNode( + name: NameNode(value: '__typename'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + ]), + ), +]); +Mutation$CreateToken _parserFn$Mutation$CreateToken( + Map data) => + Mutation$CreateToken.fromJson(data); +typedef OnMutationCompleted$Mutation$CreateToken = FutureOr Function( + Map?, + Mutation$CreateToken?, +); + +class Options$Mutation$CreateToken + extends graphql.MutationOptions { + Options$Mutation$CreateToken({ + String? operationName, + required Variables$Mutation$CreateToken variables, + graphql.FetchPolicy? fetchPolicy, + graphql.ErrorPolicy? errorPolicy, + graphql.CacheRereadPolicy? cacheRereadPolicy, + Object? optimisticResult, + Mutation$CreateToken? typedOptimisticResult, + graphql.Context? context, + OnMutationCompleted$Mutation$CreateToken? onCompleted, + graphql.OnMutationUpdate? update, + graphql.OnError? onError, + }) : onCompletedWithParsed = onCompleted, + super( + variables: variables.toJson(), + operationName: operationName, + fetchPolicy: fetchPolicy, + errorPolicy: errorPolicy, + cacheRereadPolicy: cacheRereadPolicy, + optimisticResult: optimisticResult ?? typedOptimisticResult?.toJson(), + context: context, + onCompleted: onCompleted == null + ? null + : (data) => onCompleted( + data, + data == null ? null : _parserFn$Mutation$CreateToken(data), + ), + update: update, + onError: onError, + document: documentNodeMutationCreateToken, + parserFn: _parserFn$Mutation$CreateToken, + ); + + final OnMutationCompleted$Mutation$CreateToken? onCompletedWithParsed; + + @override + List get properties => [ + ...super.onCompleted == null + ? super.properties + : super.properties.where((property) => property != onCompleted), + onCompletedWithParsed, + ]; +} + +class WatchOptions$Mutation$CreateToken + extends graphql.WatchQueryOptions { + WatchOptions$Mutation$CreateToken({ + String? operationName, + required Variables$Mutation$CreateToken variables, + graphql.FetchPolicy? fetchPolicy, + graphql.ErrorPolicy? errorPolicy, + graphql.CacheRereadPolicy? cacheRereadPolicy, + Object? optimisticResult, + Mutation$CreateToken? typedOptimisticResult, + graphql.Context? context, + Duration? pollInterval, + bool? eagerlyFetchResults, + bool carryForwardDataOnException = true, + bool fetchResults = false, + }) : super( + variables: variables.toJson(), + operationName: operationName, + fetchPolicy: fetchPolicy, + errorPolicy: errorPolicy, + cacheRereadPolicy: cacheRereadPolicy, + optimisticResult: optimisticResult ?? typedOptimisticResult?.toJson(), + context: context, + document: documentNodeMutationCreateToken, + pollInterval: pollInterval, + eagerlyFetchResults: eagerlyFetchResults, + carryForwardDataOnException: carryForwardDataOnException, + fetchResults: fetchResults, + parserFn: _parserFn$Mutation$CreateToken, + ); +} + +extension ClientExtension$Mutation$CreateToken on graphql.GraphQLClient { + Future> mutate$CreateToken( + Options$Mutation$CreateToken options) async => + await this.mutate(options); + graphql.ObservableQuery watchMutation$CreateToken( + WatchOptions$Mutation$CreateToken options) => + this.watchMutation(options); +} + +class Mutation$CreateToken$createToken { + Mutation$CreateToken$createToken({ + required this.uuid, + required this.value, + this.$__typename = 'TokenWithValue', + }); + + factory Mutation$CreateToken$createToken.fromJson(Map json) { + final l$uuid = json['uuid']; + final l$value = json['value']; + final l$$__typename = json['__typename']; + return Mutation$CreateToken$createToken( + uuid: (l$uuid as String), + value: (l$value as String), + $__typename: (l$$__typename as String), + ); + } + + final String uuid; + + final String value; + + final String $__typename; + + Map toJson() { + final _resultData = {}; + final l$uuid = uuid; + _resultData['uuid'] = l$uuid; + final l$value = value; + _resultData['value'] = l$value; + final l$$__typename = $__typename; + _resultData['__typename'] = l$$__typename; + return _resultData; + } + + @override + int get hashCode { + final l$uuid = uuid; + final l$value = value; + final l$$__typename = $__typename; + return Object.hashAll([ + l$uuid, + l$value, + l$$__typename, + ]); + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) { + return true; + } + if (!(other is Mutation$CreateToken$createToken) || + runtimeType != other.runtimeType) { + return false; + } + final l$uuid = uuid; + final lOther$uuid = other.uuid; + if (l$uuid != lOther$uuid) { + return false; + } + final l$value = value; + final lOther$value = other.value; + if (l$value != lOther$value) { + return false; + } + final l$$__typename = $__typename; + final lOther$$__typename = other.$__typename; + if (l$$__typename != lOther$$__typename) { + return false; + } + return true; + } +} + +extension UtilityExtension$Mutation$CreateToken$createToken + on Mutation$CreateToken$createToken { + CopyWith$Mutation$CreateToken$createToken + get copyWith => CopyWith$Mutation$CreateToken$createToken( + this, + (i) => i, + ); +} + +abstract class CopyWith$Mutation$CreateToken$createToken { + factory CopyWith$Mutation$CreateToken$createToken( + Mutation$CreateToken$createToken instance, + TRes Function(Mutation$CreateToken$createToken) then, + ) = _CopyWithImpl$Mutation$CreateToken$createToken; + + factory CopyWith$Mutation$CreateToken$createToken.stub(TRes res) = + _CopyWithStubImpl$Mutation$CreateToken$createToken; + + TRes call({ + String? uuid, + String? value, + String? $__typename, + }); +} + +class _CopyWithImpl$Mutation$CreateToken$createToken + implements CopyWith$Mutation$CreateToken$createToken { + _CopyWithImpl$Mutation$CreateToken$createToken( + this._instance, + this._then, + ); + + final Mutation$CreateToken$createToken _instance; + + final TRes Function(Mutation$CreateToken$createToken) _then; + + static const _undefined = {}; + + TRes call({ + Object? uuid = _undefined, + Object? value = _undefined, + Object? $__typename = _undefined, + }) => + _then(Mutation$CreateToken$createToken( + uuid: uuid == _undefined || uuid == null + ? _instance.uuid + : (uuid as String), + value: value == _undefined || value == null + ? _instance.value + : (value as String), + $__typename: $__typename == _undefined || $__typename == null + ? _instance.$__typename + : ($__typename as String), + )); +} + +class _CopyWithStubImpl$Mutation$CreateToken$createToken + implements CopyWith$Mutation$CreateToken$createToken { + _CopyWithStubImpl$Mutation$CreateToken$createToken(this._res); + + TRes _res; + + call({ + String? uuid, + String? value, + String? $__typename, + }) => + _res; +} + +class Variables$Mutation$DeleteToken { + factory Variables$Mutation$DeleteToken({ + required String orgSlug, + required String tokenUuid, + }) => + Variables$Mutation$DeleteToken._({ + r'orgSlug': orgSlug, + r'tokenUuid': tokenUuid, + }); + + Variables$Mutation$DeleteToken._(this._$data); + + factory Variables$Mutation$DeleteToken.fromJson(Map data) { + final result$data = {}; + final l$orgSlug = data['orgSlug']; + result$data['orgSlug'] = (l$orgSlug as String); + final l$tokenUuid = data['tokenUuid']; + result$data['tokenUuid'] = (l$tokenUuid as String); + return Variables$Mutation$DeleteToken._(result$data); + } + + Map _$data; + + String get orgSlug => (_$data['orgSlug'] as String); + + String get tokenUuid => (_$data['tokenUuid'] as String); + + Map toJson() { + final result$data = {}; + final l$orgSlug = orgSlug; + result$data['orgSlug'] = l$orgSlug; + final l$tokenUuid = tokenUuid; + result$data['tokenUuid'] = l$tokenUuid; + return result$data; + } + + CopyWith$Variables$Mutation$DeleteToken + get copyWith => CopyWith$Variables$Mutation$DeleteToken( + this, + (i) => i, + ); + + @override + bool operator ==(Object other) { + if (identical(this, other)) { + return true; + } + if (!(other is Variables$Mutation$DeleteToken) || + runtimeType != other.runtimeType) { + return false; + } + final l$orgSlug = orgSlug; + final lOther$orgSlug = other.orgSlug; + if (l$orgSlug != lOther$orgSlug) { + return false; + } + final l$tokenUuid = tokenUuid; + final lOther$tokenUuid = other.tokenUuid; + if (l$tokenUuid != lOther$tokenUuid) { + return false; + } + return true; + } + + @override + int get hashCode { + final l$orgSlug = orgSlug; + final l$tokenUuid = tokenUuid; + return Object.hashAll([ + l$orgSlug, + l$tokenUuid, + ]); + } +} + +abstract class CopyWith$Variables$Mutation$DeleteToken { + factory CopyWith$Variables$Mutation$DeleteToken( + Variables$Mutation$DeleteToken instance, + TRes Function(Variables$Mutation$DeleteToken) then, + ) = _CopyWithImpl$Variables$Mutation$DeleteToken; + + factory CopyWith$Variables$Mutation$DeleteToken.stub(TRes res) = + _CopyWithStubImpl$Variables$Mutation$DeleteToken; + + TRes call({ + String? orgSlug, + String? tokenUuid, + }); +} + +class _CopyWithImpl$Variables$Mutation$DeleteToken + implements CopyWith$Variables$Mutation$DeleteToken { + _CopyWithImpl$Variables$Mutation$DeleteToken( + this._instance, + this._then, + ); + + final Variables$Mutation$DeleteToken _instance; + + final TRes Function(Variables$Mutation$DeleteToken) _then; + + static const _undefined = {}; + + TRes call({ + Object? orgSlug = _undefined, + Object? tokenUuid = _undefined, + }) => + _then(Variables$Mutation$DeleteToken._({ + ..._instance._$data, + if (orgSlug != _undefined && orgSlug != null) + 'orgSlug': (orgSlug as String), + if (tokenUuid != _undefined && tokenUuid != null) + 'tokenUuid': (tokenUuid as String), + })); +} + +class _CopyWithStubImpl$Variables$Mutation$DeleteToken + implements CopyWith$Variables$Mutation$DeleteToken { + _CopyWithStubImpl$Variables$Mutation$DeleteToken(this._res); + + TRes _res; + + call({ + String? orgSlug, + String? tokenUuid, + }) => + _res; +} + +class Mutation$DeleteToken { + Mutation$DeleteToken({ + required this.deleteToken, + this.$__typename = 'Mutation', + }); + + factory Mutation$DeleteToken.fromJson(Map json) { + final l$deleteToken = json['deleteToken']; + final l$$__typename = json['__typename']; + return Mutation$DeleteToken( + deleteToken: Mutation$DeleteToken$deleteToken.fromJson( + (l$deleteToken as Map)), + $__typename: (l$$__typename as String), + ); + } + + final Mutation$DeleteToken$deleteToken deleteToken; + + final String $__typename; + + Map toJson() { + final _resultData = {}; + final l$deleteToken = deleteToken; + _resultData['deleteToken'] = l$deleteToken.toJson(); + final l$$__typename = $__typename; + _resultData['__typename'] = l$$__typename; + return _resultData; + } + + @override + int get hashCode { + final l$deleteToken = deleteToken; + final l$$__typename = $__typename; + return Object.hashAll([ + l$deleteToken, + l$$__typename, + ]); + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) { + return true; + } + if (!(other is Mutation$DeleteToken) || runtimeType != other.runtimeType) { + return false; + } + final l$deleteToken = deleteToken; + final lOther$deleteToken = other.deleteToken; + if (l$deleteToken != lOther$deleteToken) { + return false; + } + final l$$__typename = $__typename; + final lOther$$__typename = other.$__typename; + if (l$$__typename != lOther$$__typename) { + return false; + } + return true; + } +} + +extension UtilityExtension$Mutation$DeleteToken on Mutation$DeleteToken { + CopyWith$Mutation$DeleteToken get copyWith => + CopyWith$Mutation$DeleteToken( + this, + (i) => i, + ); +} + +abstract class CopyWith$Mutation$DeleteToken { + factory CopyWith$Mutation$DeleteToken( + Mutation$DeleteToken instance, + TRes Function(Mutation$DeleteToken) then, + ) = _CopyWithImpl$Mutation$DeleteToken; + + factory CopyWith$Mutation$DeleteToken.stub(TRes res) = + _CopyWithStubImpl$Mutation$DeleteToken; + + TRes call({ + Mutation$DeleteToken$deleteToken? deleteToken, + String? $__typename, + }); + CopyWith$Mutation$DeleteToken$deleteToken get deleteToken; +} + +class _CopyWithImpl$Mutation$DeleteToken + implements CopyWith$Mutation$DeleteToken { + _CopyWithImpl$Mutation$DeleteToken( + this._instance, + this._then, + ); + + final Mutation$DeleteToken _instance; + + final TRes Function(Mutation$DeleteToken) _then; + + static const _undefined = {}; + + TRes call({ + Object? deleteToken = _undefined, + Object? $__typename = _undefined, + }) => + _then(Mutation$DeleteToken( + deleteToken: deleteToken == _undefined || deleteToken == null + ? _instance.deleteToken + : (deleteToken as Mutation$DeleteToken$deleteToken), + $__typename: $__typename == _undefined || $__typename == null + ? _instance.$__typename + : ($__typename as String), + )); + + CopyWith$Mutation$DeleteToken$deleteToken get deleteToken { + final local$deleteToken = _instance.deleteToken; + return CopyWith$Mutation$DeleteToken$deleteToken( + local$deleteToken, (e) => call(deleteToken: e)); + } +} + +class _CopyWithStubImpl$Mutation$DeleteToken + implements CopyWith$Mutation$DeleteToken { + _CopyWithStubImpl$Mutation$DeleteToken(this._res); + + TRes _res; + + call({ + Mutation$DeleteToken$deleteToken? deleteToken, + String? $__typename, + }) => + _res; + + CopyWith$Mutation$DeleteToken$deleteToken get deleteToken => + CopyWith$Mutation$DeleteToken$deleteToken.stub(_res); +} + +const documentNodeMutationDeleteToken = DocumentNode(definitions: [ + OperationDefinitionNode( + type: OperationType.mutation, + name: NameNode(value: 'DeleteToken'), + variableDefinitions: [ + VariableDefinitionNode( + variable: VariableNode(name: NameNode(value: 'orgSlug')), + type: NamedTypeNode( + name: NameNode(value: 'String'), + isNonNull: true, + ), + defaultValue: DefaultValueNode(value: null), + directives: [], + ), + VariableDefinitionNode( + variable: VariableNode(name: NameNode(value: 'tokenUuid')), + type: NamedTypeNode( + name: NameNode(value: 'String'), + isNonNull: true, + ), + defaultValue: DefaultValueNode(value: null), + directives: [], + ), + ], + directives: [], + selectionSet: SelectionSetNode(selections: [ + FieldNode( + name: NameNode(value: 'deleteToken'), + alias: null, + arguments: [ + ArgumentNode( + name: NameNode(value: 'uuid'), + value: VariableNode(name: NameNode(value: 'tokenUuid')), + ), + ArgumentNode( + name: NameNode(value: 'orgSlug'), + value: VariableNode(name: NameNode(value: 'orgSlug')), + ), + ], + directives: [], + selectionSet: SelectionSetNode(selections: [ + FieldNode( + name: NameNode(value: 'message'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + FieldNode( + name: NameNode(value: '__typename'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + ]), + ), + FieldNode( + name: NameNode(value: '__typename'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + ]), + ), +]); +Mutation$DeleteToken _parserFn$Mutation$DeleteToken( + Map data) => + Mutation$DeleteToken.fromJson(data); +typedef OnMutationCompleted$Mutation$DeleteToken = FutureOr Function( + Map?, + Mutation$DeleteToken?, +); + +class Options$Mutation$DeleteToken + extends graphql.MutationOptions { + Options$Mutation$DeleteToken({ + String? operationName, + required Variables$Mutation$DeleteToken variables, + graphql.FetchPolicy? fetchPolicy, + graphql.ErrorPolicy? errorPolicy, + graphql.CacheRereadPolicy? cacheRereadPolicy, + Object? optimisticResult, + Mutation$DeleteToken? typedOptimisticResult, + graphql.Context? context, + OnMutationCompleted$Mutation$DeleteToken? onCompleted, + graphql.OnMutationUpdate? update, + graphql.OnError? onError, + }) : onCompletedWithParsed = onCompleted, + super( + variables: variables.toJson(), + operationName: operationName, + fetchPolicy: fetchPolicy, + errorPolicy: errorPolicy, + cacheRereadPolicy: cacheRereadPolicy, + optimisticResult: optimisticResult ?? typedOptimisticResult?.toJson(), + context: context, + onCompleted: onCompleted == null + ? null + : (data) => onCompleted( + data, + data == null ? null : _parserFn$Mutation$DeleteToken(data), + ), + update: update, + onError: onError, + document: documentNodeMutationDeleteToken, + parserFn: _parserFn$Mutation$DeleteToken, + ); + + final OnMutationCompleted$Mutation$DeleteToken? onCompletedWithParsed; + + @override + List get properties => [ + ...super.onCompleted == null + ? super.properties + : super.properties.where((property) => property != onCompleted), + onCompletedWithParsed, + ]; +} + +class WatchOptions$Mutation$DeleteToken + extends graphql.WatchQueryOptions { + WatchOptions$Mutation$DeleteToken({ + String? operationName, + required Variables$Mutation$DeleteToken variables, + graphql.FetchPolicy? fetchPolicy, + graphql.ErrorPolicy? errorPolicy, + graphql.CacheRereadPolicy? cacheRereadPolicy, + Object? optimisticResult, + Mutation$DeleteToken? typedOptimisticResult, + graphql.Context? context, + Duration? pollInterval, + bool? eagerlyFetchResults, + bool carryForwardDataOnException = true, + bool fetchResults = false, + }) : super( + variables: variables.toJson(), + operationName: operationName, + fetchPolicy: fetchPolicy, + errorPolicy: errorPolicy, + cacheRereadPolicy: cacheRereadPolicy, + optimisticResult: optimisticResult ?? typedOptimisticResult?.toJson(), + context: context, + document: documentNodeMutationDeleteToken, + pollInterval: pollInterval, + eagerlyFetchResults: eagerlyFetchResults, + carryForwardDataOnException: carryForwardDataOnException, + fetchResults: fetchResults, + parserFn: _parserFn$Mutation$DeleteToken, + ); +} + +extension ClientExtension$Mutation$DeleteToken on graphql.GraphQLClient { + Future> mutate$DeleteToken( + Options$Mutation$DeleteToken options) async => + await this.mutate(options); + graphql.ObservableQuery watchMutation$DeleteToken( + WatchOptions$Mutation$DeleteToken options) => + this.watchMutation(options); +} + +class Mutation$DeleteToken$deleteToken { + Mutation$DeleteToken$deleteToken({ + required this.message, + this.$__typename = 'SuccessResponse', + }); + + factory Mutation$DeleteToken$deleteToken.fromJson(Map json) { + final l$message = json['message']; + final l$$__typename = json['__typename']; + return Mutation$DeleteToken$deleteToken( + message: (l$message as String), + $__typename: (l$$__typename as String), + ); + } + + final String message; + + final String $__typename; + + Map toJson() { + final _resultData = {}; + final l$message = message; + _resultData['message'] = l$message; + final l$$__typename = $__typename; + _resultData['__typename'] = l$$__typename; + return _resultData; + } + + @override + int get hashCode { + final l$message = message; + final l$$__typename = $__typename; + return Object.hashAll([ + l$message, + l$$__typename, + ]); + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) { + return true; + } + if (!(other is Mutation$DeleteToken$deleteToken) || + runtimeType != other.runtimeType) { + return false; + } + final l$message = message; + final lOther$message = other.message; + if (l$message != lOther$message) { + return false; + } + final l$$__typename = $__typename; + final lOther$$__typename = other.$__typename; + if (l$$__typename != lOther$$__typename) { + return false; + } + return true; + } +} + +extension UtilityExtension$Mutation$DeleteToken$deleteToken + on Mutation$DeleteToken$deleteToken { + CopyWith$Mutation$DeleteToken$deleteToken + get copyWith => CopyWith$Mutation$DeleteToken$deleteToken( + this, + (i) => i, + ); +} + +abstract class CopyWith$Mutation$DeleteToken$deleteToken { + factory CopyWith$Mutation$DeleteToken$deleteToken( + Mutation$DeleteToken$deleteToken instance, + TRes Function(Mutation$DeleteToken$deleteToken) then, + ) = _CopyWithImpl$Mutation$DeleteToken$deleteToken; + + factory CopyWith$Mutation$DeleteToken$deleteToken.stub(TRes res) = + _CopyWithStubImpl$Mutation$DeleteToken$deleteToken; + + TRes call({ + String? message, + String? $__typename, + }); +} + +class _CopyWithImpl$Mutation$DeleteToken$deleteToken + implements CopyWith$Mutation$DeleteToken$deleteToken { + _CopyWithImpl$Mutation$DeleteToken$deleteToken( + this._instance, + this._then, + ); + + final Mutation$DeleteToken$deleteToken _instance; + + final TRes Function(Mutation$DeleteToken$deleteToken) _then; + + static const _undefined = {}; + + TRes call({ + Object? message = _undefined, + Object? $__typename = _undefined, + }) => + _then(Mutation$DeleteToken$deleteToken( + message: message == _undefined || message == null + ? _instance.message + : (message as String), + $__typename: $__typename == _undefined || $__typename == null + ? _instance.$__typename + : ($__typename as String), + )); +} + +class _CopyWithStubImpl$Mutation$DeleteToken$deleteToken + implements CopyWith$Mutation$DeleteToken$deleteToken { + _CopyWithStubImpl$Mutation$DeleteToken$deleteToken(this._res); + + TRes _res; + + call({ + String? message, + String? $__typename, + }) => + _res; +} + +class Variables$Query$ListTokens { + factory Variables$Query$ListTokens({ + required String orgSlug, + required List projects, + }) => + Variables$Query$ListTokens._({ + r'orgSlug': orgSlug, + r'projects': projects, + }); + + Variables$Query$ListTokens._(this._$data); + + factory Variables$Query$ListTokens.fromJson(Map data) { + final result$data = {}; + final l$orgSlug = data['orgSlug']; + result$data['orgSlug'] = (l$orgSlug as String); + final l$projects = data['projects']; + result$data['projects'] = + (l$projects as List).map((e) => (e as String)).toList(); + return Variables$Query$ListTokens._(result$data); + } + + Map _$data; + + String get orgSlug => (_$data['orgSlug'] as String); + + List get projects => (_$data['projects'] as List); + + Map toJson() { + final result$data = {}; + final l$orgSlug = orgSlug; + result$data['orgSlug'] = l$orgSlug; + final l$projects = projects; + result$data['projects'] = l$projects.map((e) => e).toList(); + return result$data; + } + + CopyWith$Variables$Query$ListTokens + get copyWith => CopyWith$Variables$Query$ListTokens( + this, + (i) => i, + ); + + @override + bool operator ==(Object other) { + if (identical(this, other)) { + return true; + } + if (!(other is Variables$Query$ListTokens) || + runtimeType != other.runtimeType) { + return false; + } + final l$orgSlug = orgSlug; + final lOther$orgSlug = other.orgSlug; + if (l$orgSlug != lOther$orgSlug) { + return false; + } + final l$projects = projects; + final lOther$projects = other.projects; + if (l$projects.length != lOther$projects.length) { + return false; + } + for (int i = 0; i < l$projects.length; i++) { + final l$projects$entry = l$projects[i]; + final lOther$projects$entry = lOther$projects[i]; + if (l$projects$entry != lOther$projects$entry) { + return false; + } + } + return true; + } + + @override + int get hashCode { + final l$orgSlug = orgSlug; + final l$projects = projects; + return Object.hashAll([ + l$orgSlug, + Object.hashAll(l$projects.map((v) => v)), + ]); + } +} + +abstract class CopyWith$Variables$Query$ListTokens { + factory CopyWith$Variables$Query$ListTokens( + Variables$Query$ListTokens instance, + TRes Function(Variables$Query$ListTokens) then, + ) = _CopyWithImpl$Variables$Query$ListTokens; + + factory CopyWith$Variables$Query$ListTokens.stub(TRes res) = + _CopyWithStubImpl$Variables$Query$ListTokens; + + TRes call({ + String? orgSlug, + List? projects, + }); +} + +class _CopyWithImpl$Variables$Query$ListTokens + implements CopyWith$Variables$Query$ListTokens { + _CopyWithImpl$Variables$Query$ListTokens( + this._instance, + this._then, + ); + + final Variables$Query$ListTokens _instance; + + final TRes Function(Variables$Query$ListTokens) _then; + + static const _undefined = {}; + + TRes call({ + Object? orgSlug = _undefined, + Object? projects = _undefined, + }) => + _then(Variables$Query$ListTokens._({ + ..._instance._$data, + if (orgSlug != _undefined && orgSlug != null) + 'orgSlug': (orgSlug as String), + if (projects != _undefined && projects != null) + 'projects': (projects as List), + })); +} + +class _CopyWithStubImpl$Variables$Query$ListTokens + implements CopyWith$Variables$Query$ListTokens { + _CopyWithStubImpl$Variables$Query$ListTokens(this._res); + + TRes _res; + + call({ + String? orgSlug, + List? projects, + }) => + _res; +} + +class Query$ListTokens { + Query$ListTokens({ + required this.tokens, + this.$__typename = 'Query', + }); + + factory Query$ListTokens.fromJson(Map json) { + final l$tokens = json['tokens']; + final l$$__typename = json['__typename']; + return Query$ListTokens( + tokens: (l$tokens as List) + .map((e) => + Query$ListTokens$tokens.fromJson((e as Map))) + .toList(), + $__typename: (l$$__typename as String), + ); + } + + final List tokens; + + final String $__typename; + + Map toJson() { + final _resultData = {}; + final l$tokens = tokens; + _resultData['tokens'] = l$tokens.map((e) => e.toJson()).toList(); + final l$$__typename = $__typename; + _resultData['__typename'] = l$$__typename; + return _resultData; + } + + @override + int get hashCode { + final l$tokens = tokens; + final l$$__typename = $__typename; + return Object.hashAll([ + Object.hashAll(l$tokens.map((v) => v)), + l$$__typename, + ]); + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) { + return true; + } + if (!(other is Query$ListTokens) || runtimeType != other.runtimeType) { + return false; + } + final l$tokens = tokens; + final lOther$tokens = other.tokens; + if (l$tokens.length != lOther$tokens.length) { + return false; + } + for (int i = 0; i < l$tokens.length; i++) { + final l$tokens$entry = l$tokens[i]; + final lOther$tokens$entry = lOther$tokens[i]; + if (l$tokens$entry != lOther$tokens$entry) { + return false; + } + } + final l$$__typename = $__typename; + final lOther$$__typename = other.$__typename; + if (l$$__typename != lOther$$__typename) { + return false; + } + return true; + } +} + +extension UtilityExtension$Query$ListTokens on Query$ListTokens { + CopyWith$Query$ListTokens get copyWith => + CopyWith$Query$ListTokens( + this, + (i) => i, + ); +} + +abstract class CopyWith$Query$ListTokens { + factory CopyWith$Query$ListTokens( + Query$ListTokens instance, + TRes Function(Query$ListTokens) then, + ) = _CopyWithImpl$Query$ListTokens; + + factory CopyWith$Query$ListTokens.stub(TRes res) = + _CopyWithStubImpl$Query$ListTokens; + + TRes call({ + List? tokens, + String? $__typename, + }); + TRes tokens( + Iterable Function( + Iterable< + CopyWith$Query$ListTokens$tokens>) + _fn); +} + +class _CopyWithImpl$Query$ListTokens + implements CopyWith$Query$ListTokens { + _CopyWithImpl$Query$ListTokens( + this._instance, + this._then, + ); + + final Query$ListTokens _instance; + + final TRes Function(Query$ListTokens) _then; + + static const _undefined = {}; + + TRes call({ + Object? tokens = _undefined, + Object? $__typename = _undefined, + }) => + _then(Query$ListTokens( + tokens: tokens == _undefined || tokens == null + ? _instance.tokens + : (tokens as List), + $__typename: $__typename == _undefined || $__typename == null + ? _instance.$__typename + : ($__typename as String), + )); + + TRes tokens( + Iterable Function( + Iterable< + CopyWith$Query$ListTokens$tokens< + Query$ListTokens$tokens>>) + _fn) => + call( + tokens: + _fn(_instance.tokens.map((e) => CopyWith$Query$ListTokens$tokens( + e, + (i) => i, + ))).toList()); +} + +class _CopyWithStubImpl$Query$ListTokens + implements CopyWith$Query$ListTokens { + _CopyWithStubImpl$Query$ListTokens(this._res); + + TRes _res; + + call({ + List? tokens, + String? $__typename, + }) => + _res; + + tokens(_fn) => _res; +} + +const documentNodeQueryListTokens = DocumentNode(definitions: [ + OperationDefinitionNode( + type: OperationType.query, + name: NameNode(value: 'ListTokens'), + variableDefinitions: [ + VariableDefinitionNode( + variable: VariableNode(name: NameNode(value: 'orgSlug')), + type: NamedTypeNode( + name: NameNode(value: 'String'), + isNonNull: true, + ), + defaultValue: DefaultValueNode(value: null), + directives: [], + ), + VariableDefinitionNode( + variable: VariableNode(name: NameNode(value: 'projects')), + type: ListTypeNode( + type: NamedTypeNode( + name: NameNode(value: 'String'), + isNonNull: true, + ), + isNonNull: true, + ), + defaultValue: DefaultValueNode(value: null), + directives: [], + ), + ], + directives: [], + selectionSet: SelectionSetNode(selections: [ + FieldNode( + name: NameNode(value: 'tokens'), + alias: null, + arguments: [ + ArgumentNode( + name: NameNode(value: 'orgSlug'), + value: VariableNode(name: NameNode(value: 'orgSlug')), + ), + ArgumentNode( + name: NameNode(value: 'projects'), + value: VariableNode(name: NameNode(value: 'projects')), + ), + ], + directives: [], + selectionSet: SelectionSetNode(selections: [ + FieldNode( + name: NameNode(value: 'uuid'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + FieldNode( + name: NameNode(value: 'name'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + FieldNode( + name: NameNode(value: 'expiresAt'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + FieldNode( + name: NameNode(value: '__typename'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + ]), + ), + FieldNode( + name: NameNode(value: '__typename'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + ]), + ), +]); +Query$ListTokens _parserFn$Query$ListTokens(Map data) => + Query$ListTokens.fromJson(data); +typedef OnQueryComplete$Query$ListTokens = FutureOr Function( + Map?, + Query$ListTokens?, +); + +class Options$Query$ListTokens extends graphql.QueryOptions { + Options$Query$ListTokens({ + String? operationName, + required Variables$Query$ListTokens variables, + graphql.FetchPolicy? fetchPolicy, + graphql.ErrorPolicy? errorPolicy, + graphql.CacheRereadPolicy? cacheRereadPolicy, + Object? optimisticResult, + Query$ListTokens? typedOptimisticResult, + Duration? pollInterval, + graphql.Context? context, + OnQueryComplete$Query$ListTokens? onComplete, + graphql.OnQueryError? onError, + }) : onCompleteWithParsed = onComplete, + super( + variables: variables.toJson(), + operationName: operationName, + fetchPolicy: fetchPolicy, + errorPolicy: errorPolicy, + cacheRereadPolicy: cacheRereadPolicy, + optimisticResult: optimisticResult ?? typedOptimisticResult?.toJson(), + pollInterval: pollInterval, + context: context, + onComplete: onComplete == null + ? null + : (data) => onComplete( + data, + data == null ? null : _parserFn$Query$ListTokens(data), + ), + onError: onError, + document: documentNodeQueryListTokens, + parserFn: _parserFn$Query$ListTokens, + ); + + final OnQueryComplete$Query$ListTokens? onCompleteWithParsed; + + @override + List get properties => [ + ...super.onComplete == null + ? super.properties + : super.properties.where((property) => property != onComplete), + onCompleteWithParsed, + ]; +} + +class WatchOptions$Query$ListTokens + extends graphql.WatchQueryOptions { + WatchOptions$Query$ListTokens({ + String? operationName, + required Variables$Query$ListTokens variables, + graphql.FetchPolicy? fetchPolicy, + graphql.ErrorPolicy? errorPolicy, + graphql.CacheRereadPolicy? cacheRereadPolicy, + Object? optimisticResult, + Query$ListTokens? typedOptimisticResult, + graphql.Context? context, + Duration? pollInterval, + bool? eagerlyFetchResults, + bool carryForwardDataOnException = true, + bool fetchResults = false, + }) : super( + variables: variables.toJson(), + operationName: operationName, + fetchPolicy: fetchPolicy, + errorPolicy: errorPolicy, + cacheRereadPolicy: cacheRereadPolicy, + optimisticResult: optimisticResult ?? typedOptimisticResult?.toJson(), + context: context, + document: documentNodeQueryListTokens, + pollInterval: pollInterval, + eagerlyFetchResults: eagerlyFetchResults, + carryForwardDataOnException: carryForwardDataOnException, + fetchResults: fetchResults, + parserFn: _parserFn$Query$ListTokens, + ); +} + +class FetchMoreOptions$Query$ListTokens extends graphql.FetchMoreOptions { + FetchMoreOptions$Query$ListTokens({ + required graphql.UpdateQuery updateQuery, + required Variables$Query$ListTokens variables, + }) : super( + updateQuery: updateQuery, + variables: variables.toJson(), + document: documentNodeQueryListTokens, + ); +} + +extension ClientExtension$Query$ListTokens on graphql.GraphQLClient { + Future> query$ListTokens( + Options$Query$ListTokens options) async => + await this.query(options); + graphql.ObservableQuery watchQuery$ListTokens( + WatchOptions$Query$ListTokens options) => + this.watchQuery(options); + void writeQuery$ListTokens({ + required Query$ListTokens data, + required Variables$Query$ListTokens variables, + bool broadcast = true, + }) => + this.writeQuery( + graphql.Request( + operation: graphql.Operation(document: documentNodeQueryListTokens), + variables: variables.toJson(), + ), + data: data.toJson(), + broadcast: broadcast, + ); + Query$ListTokens? readQuery$ListTokens({ + required Variables$Query$ListTokens variables, + bool optimistic = true, + }) { + final result = this.readQuery( + graphql.Request( + operation: graphql.Operation(document: documentNodeQueryListTokens), + variables: variables.toJson(), + ), + optimistic: optimistic, + ); + return result == null ? null : Query$ListTokens.fromJson(result); + } +} + +class Query$ListTokens$tokens { + Query$ListTokens$tokens({ + required this.uuid, + required this.name, + required this.expiresAt, + this.$__typename = 'Token', + }); + + factory Query$ListTokens$tokens.fromJson(Map json) { + final l$uuid = json['uuid']; + final l$name = json['name']; + final l$expiresAt = json['expiresAt']; + final l$$__typename = json['__typename']; + return Query$ListTokens$tokens( + uuid: (l$uuid as String), + name: (l$name as String), + expiresAt: (l$expiresAt as String), + $__typename: (l$$__typename as String), + ); + } + + final String uuid; + + final String name; + + final String expiresAt; + + final String $__typename; + + Map toJson() { + final _resultData = {}; + final l$uuid = uuid; + _resultData['uuid'] = l$uuid; + final l$name = name; + _resultData['name'] = l$name; + final l$expiresAt = expiresAt; + _resultData['expiresAt'] = l$expiresAt; + final l$$__typename = $__typename; + _resultData['__typename'] = l$$__typename; + return _resultData; + } + + @override + int get hashCode { + final l$uuid = uuid; + final l$name = name; + final l$expiresAt = expiresAt; + final l$$__typename = $__typename; + return Object.hashAll([ + l$uuid, + l$name, + l$expiresAt, + l$$__typename, + ]); + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) { + return true; + } + if (!(other is Query$ListTokens$tokens) || + runtimeType != other.runtimeType) { + return false; + } + final l$uuid = uuid; + final lOther$uuid = other.uuid; + if (l$uuid != lOther$uuid) { + return false; + } + final l$name = name; + final lOther$name = other.name; + if (l$name != lOther$name) { + return false; + } + final l$expiresAt = expiresAt; + final lOther$expiresAt = other.expiresAt; + if (l$expiresAt != lOther$expiresAt) { + return false; + } + final l$$__typename = $__typename; + final lOther$$__typename = other.$__typename; + if (l$$__typename != lOther$$__typename) { + return false; + } + return true; + } +} + +extension UtilityExtension$Query$ListTokens$tokens on Query$ListTokens$tokens { + CopyWith$Query$ListTokens$tokens get copyWith => + CopyWith$Query$ListTokens$tokens( + this, + (i) => i, + ); +} + +abstract class CopyWith$Query$ListTokens$tokens { + factory CopyWith$Query$ListTokens$tokens( + Query$ListTokens$tokens instance, + TRes Function(Query$ListTokens$tokens) then, + ) = _CopyWithImpl$Query$ListTokens$tokens; + + factory CopyWith$Query$ListTokens$tokens.stub(TRes res) = + _CopyWithStubImpl$Query$ListTokens$tokens; + + TRes call({ + String? uuid, + String? name, + String? expiresAt, + String? $__typename, + }); +} + +class _CopyWithImpl$Query$ListTokens$tokens + implements CopyWith$Query$ListTokens$tokens { + _CopyWithImpl$Query$ListTokens$tokens( + this._instance, + this._then, + ); + + final Query$ListTokens$tokens _instance; + + final TRes Function(Query$ListTokens$tokens) _then; + + static const _undefined = {}; + + TRes call({ + Object? uuid = _undefined, + Object? name = _undefined, + Object? expiresAt = _undefined, + Object? $__typename = _undefined, + }) => + _then(Query$ListTokens$tokens( + uuid: uuid == _undefined || uuid == null + ? _instance.uuid + : (uuid as String), + name: name == _undefined || name == null + ? _instance.name + : (name as String), + expiresAt: expiresAt == _undefined || expiresAt == null + ? _instance.expiresAt + : (expiresAt as String), + $__typename: $__typename == _undefined || $__typename == null + ? _instance.$__typename + : ($__typename as String), + )); +} + +class _CopyWithStubImpl$Query$ListTokens$tokens + implements CopyWith$Query$ListTokens$tokens { + _CopyWithStubImpl$Query$ListTokens$tokens(this._res); + + TRes _res; + + call({ + String? uuid, + String? name, + String? expiresAt, + String? $__typename, + }) => + _res; +} diff --git a/packages/globe_cli/lib/src/commands/token/token_create_command.dart b/packages/globe_cli/lib/src/commands/token/token_create_command.dart index 6bb28b3..b98e6f1 100644 --- a/packages/globe_cli/lib/src/commands/token/token_create_command.dart +++ b/packages/globe_cli/lib/src/commands/token/token_create_command.dart @@ -68,7 +68,7 @@ class TokenCreateCommand extends BaseGlobeCommand { try { final token = await api.createToken( - orgId: organization.id, + orgSlug: organization.slug, name: name, projectUuids: projects.map((e) => e.id).toList(), expiresAt: expiry, diff --git a/packages/globe_cli/lib/src/commands/token/token_delete_command.dart b/packages/globe_cli/lib/src/commands/token/token_delete_command.dart index ccfde2d..6be5152 100644 --- a/packages/globe_cli/lib/src/commands/token/token_delete_command.dart +++ b/packages/globe_cli/lib/src/commands/token/token_delete_command.dart @@ -33,7 +33,7 @@ class TokenDeleteCommand extends BaseGlobeCommand { try { await api.deleteToken( - orgId: organization.id, + orgSlug: organization.slug, tokenId: tokenId, ); deleteTokenProgress.complete('Token deleted'); diff --git a/packages/globe_cli/lib/src/commands/token/token_list_command.dart b/packages/globe_cli/lib/src/commands/token/token_list_command.dart index ff7bc7e..112b235 100644 --- a/packages/globe_cli/lib/src/commands/token/token_list_command.dart +++ b/packages/globe_cli/lib/src/commands/token/token_list_command.dart @@ -5,6 +5,7 @@ import 'package:mason_logger/mason_logger.dart'; import '../../command.dart'; import '../../utils/api.dart'; import '../../utils/prompts.dart'; +import 'token.graphql.dart'; class TokenListCommand extends BaseGlobeCommand { TokenListCommand() { @@ -40,7 +41,7 @@ class TokenListCommand extends BaseGlobeCommand { try { final tokens = await api.listTokens( - orgId: organization.id, + orgSlug: organization.slug, projectUuids: projects.map((e) => e.id).toList(), ); if (tokens.isEmpty) { @@ -48,11 +49,11 @@ class TokenListCommand extends BaseGlobeCommand { return ExitCode.success.code; } - String tokenLog(Token token) => ''' + String tokenLog(Query$ListTokens$tokens token) => ''' ---------------------------------- ID: ${cyan.wrap(token.uuid)} Name: ${token.name} - Expiry: ${token.expiresAt.toLocal()}'''; + Expiry: ${token.expiresAtTime.toLocal()}'''; listTokenProgress.complete( 'Tokens for $projectNames\n${tokens.map(tokenLog).join('\n')}', diff --git a/packages/globe_cli/lib/src/utils/api.dart b/packages/globe_cli/lib/src/utils/api.dart index f2fd032..0ac7003 100644 --- a/packages/globe_cli/lib/src/utils/api.dart +++ b/packages/globe_cli/lib/src/utils/api.dart @@ -1,11 +1,16 @@ import 'dart:convert'; import 'dart:io'; +import 'package:graphql/client.dart'; import 'package:http/http.dart' as http; import 'package:mason_logger/mason_logger.dart'; import 'package:path/path.dart'; +import '../commands/organizations.graphql.dart'; +import '../commands/project/project.graphql.dart'; +import '../commands/token/token.graphql.dart'; import '../exit.dart'; +import '../graphql/project.graphql.dart'; import '../package_info.dart' as package_info; import 'auth.dart'; import 'metadata.dart'; @@ -44,12 +49,69 @@ class GlobeApi { final GlobeAuth auth; final Logger logger; + late final GraphQLClient _client = GraphQLClient( + link: Link.route( + (request) { + final buffer = StringBuffer(); + + if (request.isMutation) { + buffer.write('MUTATION'); + } else { + buffer.write('QUERY'); + } + + if (request.operation.operationName case final name?) { + buffer.write(' ($name)'); + } + + if (request.variables.isNotEmpty) { + try { + buffer.write(', Variables ${jsonEncode(request.variables)}'); + } catch (error, stackTrace) { + buffer.write( + ', Variables: ' + '\n$error' + '\n$stackTrace', + ); + } + } + + logger.detail(buffer.toString()); + + return HttpLink( + '${metadata.endpoint}/graphql', + defaultHeaders: { + if (auth.currentSession?.jwt case final jwt?) + 'Authorization': 'Bearer $jwt', + // 'Cookie': 'auth_session=zeg83dxa9kvzjosxglzkt2npc2jypab5380kyjzi' + }, + ); + }, + ), + cache: GraphQLCache(), + ); + /// Creates a [Uri] from the given [path], using the [GlobeMetadata.endpoint] as the base. Uri _buildUri(String path) { assert(path.startsWith('/'), 'path must start with a /.'); return Uri.parse('${metadata.endpoint}/api$path'); } + Future _handleGraphql( + Future> Function() cb, + ) async { + final result = await cb(); + + if (result.hasException) { + throw ApiException._( + 500, + 'An error occurred while calling the Globe API.\n$result', + ); + } + + return result.parsedData as T; + } + /// Handles an [http.Response], throwing an [ApiException] if the response /// is not successful. Object? _handleResponse(http.Response response) { @@ -110,15 +172,19 @@ class GlobeApi { /// Gets all of the organizations that the current user is a member of. Future> getOrganizations() async { requireAuth(); - logger.detail('API Request: GET /user/orgs'); - final response = _handleResponse( - await http.get(_buildUri('/user/orgs'), headers: headers), - )! as List; - return response - .cast>() - .map(Organization.fromJson) - .toList(); + final response = await _handleGraphql( + () => _client.query$Organizations(Options$Query$Organizations()), + ); + + return [ + for (final org in response.organizations!) + Organization( + id: org.id, + name: org.name, + slug: org.slug, + ), + ]; } /// Gets all of the projects that the current user is a member of. @@ -126,53 +192,78 @@ class GlobeApi { required String org, }) async { requireAuth(); - logger.detail('API Request: GET /orgs/$org/projects'); - final response = _handleResponse( - await http.get(_buildUri('/orgs/$org/projects'), headers: headers), - )! as List; - return response.cast>().map(Project.fromJson).toList(); + + final response = await _handleGraphql( + () => _client.query$Projects( + Options$Query$Projects( + variables: Variables$Query$Projects(orgSlug: org), + ), + ), + ); + + return [ + for (final project in response.projects) + Project( + id: project.id, + slug: project.slug, + paused: project.status == Enum$ProjectStatus.paused, + ), + ]; } /// Creates a new project and returns it. Future createProject({ - required String orgId, + required String orgSlug, required String name, }) async { - logger.detail('API Request: POST /orgs/$orgId/projects'); - final request = http.Request('POST', _buildUri('/orgs/$orgId/projects')); - request.headers.addAll(headers); - - request.body = jsonEncode({'name': name}); - - final response = _handleResponse( - await request.send().then(http.Response.fromStream), - )! as Map; + final response = await _handleGraphql( + () => _client.mutate$CreateProject( + Options$Mutation$CreateProject( + variables: Variables$Mutation$CreateProject( + orgSlug: orgSlug, + name: name, + ), + ), + ), + ); - return Project.fromJson(response); + return Project( + id: response.createProject.id, + slug: response.createProject.slug, + paused: response.createProject.status == Enum$ProjectStatus.paused, + ); } Future pauseProject({ - required String orgId, - required String projectId, + required String orgSlug, + required String projectSlug, }) async { - final url = '/orgs/$orgId/projects/$projectId/pause'; - logger.detail('API Request: PUT $url'); - final request = http.Request('PUT', _buildUri(url)); - request.headers.addAll(headers); - - _handleResponse(await request.send().then(http.Response.fromStream)); + await _handleGraphql( + () => _client.mutate$Pause( + Options$Mutation$Pause( + variables: Variables$Mutation$Pause( + orgSlug: orgSlug, + projectId: projectSlug, + ), + ), + ), + ); } Future resumeProject({ - required String orgId, - required String projectId, + required String orgSlug, + required String projectSlug, }) async { - final url = '/orgs/$orgId/projects/$projectId/resume'; - logger.detail('API Request: PUT $url'); - final request = http.Request('PUT', _buildUri(url)); - request.headers.addAll(headers); - - _handleResponse(await request.send().then(http.Response.fromStream)); + await _handleGraphql( + () => _client.mutate$Resume( + Options$Mutation$Resume( + variables: Variables$Mutation$Resume( + orgSlug: orgSlug, + projectId: projectSlug, + ), + ), + ), + ); } Future discoverPreset(String pubspecContent) async { @@ -245,61 +336,68 @@ class GlobeApi { } Future<({String id, String value})> createToken({ - required String orgId, + required String orgSlug, required String name, required List projectUuids, required DateTime expiresAt, }) async { requireAuth(); - final createTokenPath = '/orgs/$orgId/api-tokens'; - logger.detail('API Request: POST $createTokenPath'); - - final body = json.encode({ - 'name': name, - 'projectUuids': projectUuids, - 'expiresAt': expiresAt.toUtc().toIso8601String(), - }); - - // create token - final response = _handleResponse( - await http.post(_buildUri(createTokenPath), headers: headers, body: body), - )! as Map; - final token = Token.fromJson(response); + final response = await _handleGraphql( + () => _client.mutate$CreateToken( + Options$Mutation$CreateToken( + variables: Variables$Mutation$CreateToken( + orgSlug: orgSlug, + name: name, + projects: projectUuids, + expiresAt: expiresAt.toUtc().toIso8601String(), + ), + ), + ), + ); - return (id: token.uuid, value: token.value!); + return ( + id: response.createToken.uuid, + value: response.createToken.value, + ); } - Future> listTokens({ - required String orgId, + Future> listTokens({ + required String orgSlug, required List projectUuids, }) async { requireAuth(); - final fullUri = _buildUri('/orgs/$orgId/api-tokens') - .replace(queryParameters: {'projects': projectUuids}); - - logger.detail('API Request: GET /orgs/$orgId/api-tokens'); - final response = _handleResponse(await http.get(fullUri, headers: headers))! - as List; + final response = await _handleGraphql( + () => _client.query$ListTokens( + Options$Query$ListTokens( + variables: Variables$Query$ListTokens( + orgSlug: orgSlug, + projects: projectUuids, + ), + ), + ), + ); - return response - .map((e) => Token.fromJson(e as Map)) - .toList(); + return response.tokens; } Future deleteToken({ - required String orgId, + required String orgSlug, required String tokenId, }) async { requireAuth(); - final deleteTokenPath = '/orgs/$orgId/api-tokens/$tokenId'; - logger.detail('API Request: DELETE $deleteTokenPath'); - - _handleResponse( - await http.delete(_buildUri(deleteTokenPath), headers: headers), - )! as Map; + await _handleGraphql( + () => _client.mutate$DeleteToken( + Options$Mutation$DeleteToken( + variables: Variables$Mutation$DeleteToken( + orgSlug: orgSlug, + tokenUuid: tokenId, + ), + ), + ), + ); } } @@ -412,98 +510,23 @@ class Organization { required this.id, required this.name, required this.slug, - required this.type, - // required this.role, - required this.createdAt, - required this.updatedAt, }); - factory Organization.fromJson(Map json) { - return switch (json) { - { - 'id': final String id, - 'name': final String name, - 'type': final String type, - // 'role': final String role, - 'slug': final String slug, - 'createdAt': final String createdAt, - 'updatedAt': final String updatedAt, - } => - Organization( - id: id, - name: name, - slug: slug, - type: OrganizationType.fromString(type), - // role: Role.fromString(role), - createdAt: DateTime.parse(createdAt), - updatedAt: DateTime.parse(updatedAt), - ), - _ => throw const FormatException('Organization'), - }; - } - final String id; final String name; final String slug; - final OrganizationType type; - // final Role role; - final DateTime createdAt; - final DateTime updatedAt; } class Project { Project({ required this.id, - required this.orgId, required this.slug, required this.paused, - required this.createdAt, - required this.updatedAt, }); - factory Project.fromJson(Map json) { - return switch (json) { - { - 'id': final String id, - 'organizationId': final String organizationId, - 'slug': final String slug, - 'paused': final bool paused, - 'createdAt': final String createdAt, - 'updatedAt': final String updatedAt, - } => - Project( - id: id, - orgId: organizationId, - slug: slug, - paused: paused, - createdAt: DateTime.parse(createdAt), - updatedAt: DateTime.parse(updatedAt), - ), - { - 'id': final String id, - 'organizationId': final String organizationId, - 'slug': final String slug, - 'createdAt': final String createdAt, - 'updatedAt': final String updatedAt, - } => - Project( - id: id, - orgId: organizationId, - slug: slug, - paused: false, - createdAt: DateTime.parse(createdAt), - updatedAt: DateTime.parse(updatedAt), - ), - _ => throw const FormatException('Project'), - }; - } - final String id; - final String orgId; final String slug; final bool paused; - final DateTime createdAt; - final DateTime updatedAt; } class Deployment { @@ -670,44 +693,6 @@ enum OrganizationType { } } -class Token { - final String uuid; - final String name; - final String organizationUuid; - final DateTime expiresAt; - final List cliTokenClaimProject; - final String? value; - - const Token._({ - required this.uuid, - required this.name, - required this.organizationUuid, - required this.expiresAt, - required this.cliTokenClaimProject, - required this.value, - }); - - factory Token.fromJson(Map json) { - return switch (json) { - { - 'uuid': final String uuid, - 'name': final String name, - 'organizationUuid': final String organizationUuid, - 'expiresAt': final String expiresAt, - 'projects': final List projects, - 'value': final String? value, - } => - Token._( - uuid: uuid, - name: name, - organizationUuid: organizationUuid, - expiresAt: DateTime.parse(expiresAt), - cliTokenClaimProject: projects - .map((e) => (e as Map)['projectUuid'].toString()) - .toList(), - value: value, - ), - _ => throw const FormatException('Token'), - }; - } +extension Query$ListTokens$tokensX on Query$ListTokens$tokens { + DateTime get expiresAtTime => DateTime.parse(expiresAt); } diff --git a/packages/globe_cli/lib/src/utils/prompts.dart b/packages/globe_cli/lib/src/utils/prompts.dart index 2400da4..8ac03b9 100644 --- a/packages/globe_cli/lib/src/utils/prompts.dart +++ b/packages/globe_cli/lib/src/utils/prompts.dart @@ -266,13 +266,13 @@ Future selectProject( } final project = await api.createProject( - orgId: organization.id, + orgSlug: organization.slug, name: name, ); await api.updateSettings( projectId: project.id, - orgId: project.orgId, + orgId: organization.id, settings: ProjectSettings( rootDirectory: rootDirectory == './' ? null : rootDirectory, preset: discoveredPreset?.id, @@ -311,9 +311,7 @@ Future selectProject( ); // If the user selected to create a new project, prompt to create one. - if (selectedProject == createSymbol) { - return createProject(); - } + if (selectedProject == createSymbol) return createProject(); return projects.firstWhere((p) => p.id == selectedProject); } diff --git a/packages/globe_cli/test/mocks.dart b/packages/globe_cli/test/mocks.dart index 1848699..227c7ae 100644 --- a/packages/globe_cli/test/mocks.dart +++ b/packages/globe_cli/test/mocks.dart @@ -118,13 +118,13 @@ class GlobeApiMock extends Mock with MockMixin implements GlobeApi { @override Future resumeProject({ - required String? orgId, - required String? projectId, + required String? orgSlug, + required String? projectSlug, }) { return mockFuture( Invocation.method(#resumeProject, [], { - #orgId: orgId, - #projectId: projectId, + #orgId: orgSlug, + #projectId: projectSlug, }), ); } diff --git a/packages/globe_cli/test/project/project_resume_command_test.dart b/packages/globe_cli/test/project/project_resume_command_test.dart index d153f69..082fb84 100644 --- a/packages/globe_cli/test/project/project_resume_command_test.dart +++ b/packages/globe_cli/test/project/project_resume_command_test.dart @@ -19,28 +19,10 @@ void main() { final api = GlobeApiMock(); when(api.getOrganizations()).thenAnswer((i) async { - return [ - Organization( - createdAt: DateTime.now(), - id: 'bar', - name: 'bar', - slug: 'bar', - updatedAt: DateTime.now(), - type: OrganizationType.personal, - ), - ]; + return [Organization(id: 'bar', name: 'bar', slug: 'bar')]; }); when(api.getProjects(org: 'bar')).thenAnswer((i) async { - return [ - Project( - createdAt: DateTime.now(), - id: 'foo', - slug: 'foo', - paused: false, - orgId: 'bar', - updatedAt: DateTime.now(), - ), - ]; + return [Project(id: 'foo', slug: 'foo', paused: false)]; }); GetIt.I.registerSingleton(api); From 6c357a5ae30cc04fc5f88c2e017b329afcea3545 Mon Sep 17 00:00:00 2001 From: Remi Rousselet Date: Thu, 1 Aug 2024 14:59:28 +0200 Subject: [PATCH 4/7] Remove auth-session --- packages/globe_cli/lib/src/utils/api.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/globe_cli/lib/src/utils/api.dart b/packages/globe_cli/lib/src/utils/api.dart index 0ac7003..4e37cd6 100644 --- a/packages/globe_cli/lib/src/utils/api.dart +++ b/packages/globe_cli/lib/src/utils/api.dart @@ -83,7 +83,6 @@ class GlobeApi { defaultHeaders: { if (auth.currentSession?.jwt case final jwt?) 'Authorization': 'Bearer $jwt', - // 'Cookie': 'auth_session=zeg83dxa9kvzjosxglzkt2npc2jypab5380kyjzi' }, ); }, From 82388e33ef3933bb7db124b8feccbaade1e1c656 Mon Sep 17 00:00:00 2001 From: Remi Rousselet Date: Thu, 1 Aug 2024 15:04:35 +0200 Subject: [PATCH 5/7] Revert getOrganizations --- .../lib/src/commands/organizations.graphql | 7 - .../src/commands/organizations.graphql.dart | 501 ------------------ packages/globe_cli/lib/src/utils/api.dart | 53 +- 3 files changed, 40 insertions(+), 521 deletions(-) delete mode 100644 packages/globe_cli/lib/src/commands/organizations.graphql delete mode 100644 packages/globe_cli/lib/src/commands/organizations.graphql.dart diff --git a/packages/globe_cli/lib/src/commands/organizations.graphql b/packages/globe_cli/lib/src/commands/organizations.graphql deleted file mode 100644 index b1d8576..0000000 --- a/packages/globe_cli/lib/src/commands/organizations.graphql +++ /dev/null @@ -1,7 +0,0 @@ -query Organizations { - organizations { - id - slug - name - } -} diff --git a/packages/globe_cli/lib/src/commands/organizations.graphql.dart b/packages/globe_cli/lib/src/commands/organizations.graphql.dart deleted file mode 100644 index 11490cf..0000000 --- a/packages/globe_cli/lib/src/commands/organizations.graphql.dart +++ /dev/null @@ -1,501 +0,0 @@ -// ignore_for_file: type=lint -import 'dart:async'; -import 'package:gql/ast.dart'; -import 'package:graphql/client.dart' as graphql; - -class Query$Organizations { - Query$Organizations({ - this.organizations, - this.$__typename = 'Query', - }); - - factory Query$Organizations.fromJson(Map json) { - final l$organizations = json['organizations']; - final l$$__typename = json['__typename']; - return Query$Organizations( - organizations: (l$organizations as List?) - ?.map((e) => Query$Organizations$organizations.fromJson( - (e as Map))) - .toList(), - $__typename: (l$$__typename as String), - ); - } - - final List? organizations; - - final String $__typename; - - Map toJson() { - final _resultData = {}; - final l$organizations = organizations; - _resultData['organizations'] = - l$organizations?.map((e) => e.toJson()).toList(); - final l$$__typename = $__typename; - _resultData['__typename'] = l$$__typename; - return _resultData; - } - - @override - int get hashCode { - final l$organizations = organizations; - final l$$__typename = $__typename; - return Object.hashAll([ - l$organizations == null - ? null - : Object.hashAll(l$organizations.map((v) => v)), - l$$__typename, - ]); - } - - @override - bool operator ==(Object other) { - if (identical(this, other)) { - return true; - } - if (!(other is Query$Organizations) || runtimeType != other.runtimeType) { - return false; - } - final l$organizations = organizations; - final lOther$organizations = other.organizations; - if (l$organizations != null && lOther$organizations != null) { - if (l$organizations.length != lOther$organizations.length) { - return false; - } - for (int i = 0; i < l$organizations.length; i++) { - final l$organizations$entry = l$organizations[i]; - final lOther$organizations$entry = lOther$organizations[i]; - if (l$organizations$entry != lOther$organizations$entry) { - return false; - } - } - } else if (l$organizations != lOther$organizations) { - return false; - } - final l$$__typename = $__typename; - final lOther$$__typename = other.$__typename; - if (l$$__typename != lOther$$__typename) { - return false; - } - return true; - } -} - -extension UtilityExtension$Query$Organizations on Query$Organizations { - CopyWith$Query$Organizations get copyWith => - CopyWith$Query$Organizations( - this, - (i) => i, - ); -} - -abstract class CopyWith$Query$Organizations { - factory CopyWith$Query$Organizations( - Query$Organizations instance, - TRes Function(Query$Organizations) then, - ) = _CopyWithImpl$Query$Organizations; - - factory CopyWith$Query$Organizations.stub(TRes res) = - _CopyWithStubImpl$Query$Organizations; - - TRes call({ - List? organizations, - String? $__typename, - }); - TRes organizations( - Iterable? Function( - Iterable< - CopyWith$Query$Organizations$organizations< - Query$Organizations$organizations>>?) - _fn); -} - -class _CopyWithImpl$Query$Organizations - implements CopyWith$Query$Organizations { - _CopyWithImpl$Query$Organizations( - this._instance, - this._then, - ); - - final Query$Organizations _instance; - - final TRes Function(Query$Organizations) _then; - - static const _undefined = {}; - - TRes call({ - Object? organizations = _undefined, - Object? $__typename = _undefined, - }) => - _then(Query$Organizations( - organizations: organizations == _undefined - ? _instance.organizations - : (organizations as List?), - $__typename: $__typename == _undefined || $__typename == null - ? _instance.$__typename - : ($__typename as String), - )); - - TRes organizations( - Iterable? Function( - Iterable< - CopyWith$Query$Organizations$organizations< - Query$Organizations$organizations>>?) - _fn) => - call( - organizations: _fn(_instance.organizations - ?.map((e) => CopyWith$Query$Organizations$organizations( - e, - (i) => i, - )))?.toList()); -} - -class _CopyWithStubImpl$Query$Organizations - implements CopyWith$Query$Organizations { - _CopyWithStubImpl$Query$Organizations(this._res); - - TRes _res; - - call({ - List? organizations, - String? $__typename, - }) => - _res; - - organizations(_fn) => _res; -} - -const documentNodeQueryOrganizations = DocumentNode(definitions: [ - OperationDefinitionNode( - type: OperationType.query, - name: NameNode(value: 'Organizations'), - variableDefinitions: [], - directives: [], - selectionSet: SelectionSetNode(selections: [ - FieldNode( - name: NameNode(value: 'organizations'), - alias: null, - arguments: [], - directives: [], - selectionSet: SelectionSetNode(selections: [ - FieldNode( - name: NameNode(value: 'id'), - alias: null, - arguments: [], - directives: [], - selectionSet: null, - ), - FieldNode( - name: NameNode(value: 'slug'), - alias: null, - arguments: [], - directives: [], - selectionSet: null, - ), - FieldNode( - name: NameNode(value: 'name'), - alias: null, - arguments: [], - directives: [], - selectionSet: null, - ), - FieldNode( - name: NameNode(value: '__typename'), - alias: null, - arguments: [], - directives: [], - selectionSet: null, - ), - ]), - ), - FieldNode( - name: NameNode(value: '__typename'), - alias: null, - arguments: [], - directives: [], - selectionSet: null, - ), - ]), - ), -]); -Query$Organizations _parserFn$Query$Organizations(Map data) => - Query$Organizations.fromJson(data); -typedef OnQueryComplete$Query$Organizations = FutureOr Function( - Map?, - Query$Organizations?, -); - -class Options$Query$Organizations - extends graphql.QueryOptions { - Options$Query$Organizations({ - String? operationName, - graphql.FetchPolicy? fetchPolicy, - graphql.ErrorPolicy? errorPolicy, - graphql.CacheRereadPolicy? cacheRereadPolicy, - Object? optimisticResult, - Query$Organizations? typedOptimisticResult, - Duration? pollInterval, - graphql.Context? context, - OnQueryComplete$Query$Organizations? onComplete, - graphql.OnQueryError? onError, - }) : onCompleteWithParsed = onComplete, - super( - operationName: operationName, - fetchPolicy: fetchPolicy, - errorPolicy: errorPolicy, - cacheRereadPolicy: cacheRereadPolicy, - optimisticResult: optimisticResult ?? typedOptimisticResult?.toJson(), - pollInterval: pollInterval, - context: context, - onComplete: onComplete == null - ? null - : (data) => onComplete( - data, - data == null ? null : _parserFn$Query$Organizations(data), - ), - onError: onError, - document: documentNodeQueryOrganizations, - parserFn: _parserFn$Query$Organizations, - ); - - final OnQueryComplete$Query$Organizations? onCompleteWithParsed; - - @override - List get properties => [ - ...super.onComplete == null - ? super.properties - : super.properties.where((property) => property != onComplete), - onCompleteWithParsed, - ]; -} - -class WatchOptions$Query$Organizations - extends graphql.WatchQueryOptions { - WatchOptions$Query$Organizations({ - String? operationName, - graphql.FetchPolicy? fetchPolicy, - graphql.ErrorPolicy? errorPolicy, - graphql.CacheRereadPolicy? cacheRereadPolicy, - Object? optimisticResult, - Query$Organizations? typedOptimisticResult, - graphql.Context? context, - Duration? pollInterval, - bool? eagerlyFetchResults, - bool carryForwardDataOnException = true, - bool fetchResults = false, - }) : super( - operationName: operationName, - fetchPolicy: fetchPolicy, - errorPolicy: errorPolicy, - cacheRereadPolicy: cacheRereadPolicy, - optimisticResult: optimisticResult ?? typedOptimisticResult?.toJson(), - context: context, - document: documentNodeQueryOrganizations, - pollInterval: pollInterval, - eagerlyFetchResults: eagerlyFetchResults, - carryForwardDataOnException: carryForwardDataOnException, - fetchResults: fetchResults, - parserFn: _parserFn$Query$Organizations, - ); -} - -class FetchMoreOptions$Query$Organizations extends graphql.FetchMoreOptions { - FetchMoreOptions$Query$Organizations( - {required graphql.UpdateQuery updateQuery}) - : super( - updateQuery: updateQuery, - document: documentNodeQueryOrganizations, - ); -} - -extension ClientExtension$Query$Organizations on graphql.GraphQLClient { - Future> query$Organizations( - [Options$Query$Organizations? options]) async => - await this.query(options ?? Options$Query$Organizations()); - graphql.ObservableQuery watchQuery$Organizations( - [WatchOptions$Query$Organizations? options]) => - this.watchQuery(options ?? WatchOptions$Query$Organizations()); - void writeQuery$Organizations({ - required Query$Organizations data, - bool broadcast = true, - }) => - this.writeQuery( - graphql.Request( - operation: - graphql.Operation(document: documentNodeQueryOrganizations)), - data: data.toJson(), - broadcast: broadcast, - ); - Query$Organizations? readQuery$Organizations({bool optimistic = true}) { - final result = this.readQuery( - graphql.Request( - operation: - graphql.Operation(document: documentNodeQueryOrganizations)), - optimistic: optimistic, - ); - return result == null ? null : Query$Organizations.fromJson(result); - } -} - -class Query$Organizations$organizations { - Query$Organizations$organizations({ - required this.id, - required this.slug, - required this.name, - this.$__typename = 'Organization', - }); - - factory Query$Organizations$organizations.fromJson( - Map json) { - final l$id = json['id']; - final l$slug = json['slug']; - final l$name = json['name']; - final l$$__typename = json['__typename']; - return Query$Organizations$organizations( - id: (l$id as String), - slug: (l$slug as String), - name: (l$name as String), - $__typename: (l$$__typename as String), - ); - } - - final String id; - - final String slug; - - final String name; - - final String $__typename; - - Map toJson() { - final _resultData = {}; - final l$id = id; - _resultData['id'] = l$id; - final l$slug = slug; - _resultData['slug'] = l$slug; - final l$name = name; - _resultData['name'] = l$name; - final l$$__typename = $__typename; - _resultData['__typename'] = l$$__typename; - return _resultData; - } - - @override - int get hashCode { - final l$id = id; - final l$slug = slug; - final l$name = name; - final l$$__typename = $__typename; - return Object.hashAll([ - l$id, - l$slug, - l$name, - l$$__typename, - ]); - } - - @override - bool operator ==(Object other) { - if (identical(this, other)) { - return true; - } - if (!(other is Query$Organizations$organizations) || - runtimeType != other.runtimeType) { - return false; - } - final l$id = id; - final lOther$id = other.id; - if (l$id != lOther$id) { - return false; - } - final l$slug = slug; - final lOther$slug = other.slug; - if (l$slug != lOther$slug) { - return false; - } - final l$name = name; - final lOther$name = other.name; - if (l$name != lOther$name) { - return false; - } - final l$$__typename = $__typename; - final lOther$$__typename = other.$__typename; - if (l$$__typename != lOther$$__typename) { - return false; - } - return true; - } -} - -extension UtilityExtension$Query$Organizations$organizations - on Query$Organizations$organizations { - CopyWith$Query$Organizations$organizations - get copyWith => CopyWith$Query$Organizations$organizations( - this, - (i) => i, - ); -} - -abstract class CopyWith$Query$Organizations$organizations { - factory CopyWith$Query$Organizations$organizations( - Query$Organizations$organizations instance, - TRes Function(Query$Organizations$organizations) then, - ) = _CopyWithImpl$Query$Organizations$organizations; - - factory CopyWith$Query$Organizations$organizations.stub(TRes res) = - _CopyWithStubImpl$Query$Organizations$organizations; - - TRes call({ - String? id, - String? slug, - String? name, - String? $__typename, - }); -} - -class _CopyWithImpl$Query$Organizations$organizations - implements CopyWith$Query$Organizations$organizations { - _CopyWithImpl$Query$Organizations$organizations( - this._instance, - this._then, - ); - - final Query$Organizations$organizations _instance; - - final TRes Function(Query$Organizations$organizations) _then; - - static const _undefined = {}; - - TRes call({ - Object? id = _undefined, - Object? slug = _undefined, - Object? name = _undefined, - Object? $__typename = _undefined, - }) => - _then(Query$Organizations$organizations( - id: id == _undefined || id == null ? _instance.id : (id as String), - slug: slug == _undefined || slug == null - ? _instance.slug - : (slug as String), - name: name == _undefined || name == null - ? _instance.name - : (name as String), - $__typename: $__typename == _undefined || $__typename == null - ? _instance.$__typename - : ($__typename as String), - )); -} - -class _CopyWithStubImpl$Query$Organizations$organizations - implements CopyWith$Query$Organizations$organizations { - _CopyWithStubImpl$Query$Organizations$organizations(this._res); - - TRes _res; - - call({ - String? id, - String? slug, - String? name, - String? $__typename, - }) => - _res; -} diff --git a/packages/globe_cli/lib/src/utils/api.dart b/packages/globe_cli/lib/src/utils/api.dart index 4e37cd6..d2ba875 100644 --- a/packages/globe_cli/lib/src/utils/api.dart +++ b/packages/globe_cli/lib/src/utils/api.dart @@ -6,7 +6,6 @@ import 'package:http/http.dart' as http; import 'package:mason_logger/mason_logger.dart'; import 'package:path/path.dart'; -import '../commands/organizations.graphql.dart'; import '../commands/project/project.graphql.dart'; import '../commands/token/token.graphql.dart'; import '../exit.dart'; @@ -171,19 +170,15 @@ class GlobeApi { /// Gets all of the organizations that the current user is a member of. Future> getOrganizations() async { requireAuth(); + logger.detail('API Request: GET /user/orgs'); + final response = _handleResponse( + await http.get(_buildUri('/user/orgs'), headers: headers), + )! as List; - final response = await _handleGraphql( - () => _client.query$Organizations(Options$Query$Organizations()), - ); - - return [ - for (final org in response.organizations!) - Organization( - id: org.id, - name: org.name, - slug: org.slug, - ), - ]; + return response + .cast>() + .map(Organization.fromJson) + .toList(); } /// Gets all of the projects that the current user is a member of. @@ -509,11 +504,43 @@ class Organization { required this.id, required this.name, required this.slug, + required this.type, + // required this.role, + required this.createdAt, + required this.updatedAt, }); + factory Organization.fromJson(Map json) { + return switch (json) { + { + 'id': final String id, + 'name': final String name, + 'type': final String type, + // 'role': final String role, + 'slug': final String slug, + 'createdAt': final String createdAt, + 'updatedAt': final String updatedAt, + } => + Organization( + id: id, + name: name, + slug: slug, + type: OrganizationType.fromString(type), + // role: Role.fromString(role), + createdAt: DateTime.parse(createdAt), + updatedAt: DateTime.parse(updatedAt), + ), + _ => throw const FormatException('Organization'), + }; + } + final String id; final String name; final String slug; + final OrganizationType type; + // final Role role; + final DateTime createdAt; + final DateTime updatedAt; } class Project { From ec05d33c686beafa0489d40ee9348963eebb1604 Mon Sep 17 00:00:00 2001 From: Remi Rousselet Date: Thu, 1 Aug 2024 15:05:07 +0200 Subject: [PATCH 6/7] Revert test change --- .../test/project/project_resume_command_test.dart | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/globe_cli/test/project/project_resume_command_test.dart b/packages/globe_cli/test/project/project_resume_command_test.dart index 082fb84..64e7b8c 100644 --- a/packages/globe_cli/test/project/project_resume_command_test.dart +++ b/packages/globe_cli/test/project/project_resume_command_test.dart @@ -19,7 +19,16 @@ void main() { final api = GlobeApiMock(); when(api.getOrganizations()).thenAnswer((i) async { - return [Organization(id: 'bar', name: 'bar', slug: 'bar')]; + return [ + Organization( + createdAt: DateTime.now(), + id: 'bar', + name: 'bar', + slug: 'bar', + updatedAt: DateTime.now(), + type: OrganizationType.personal, + ), + ]; }); when(api.getProjects(org: 'bar')).thenAnswer((i) async { return [Project(id: 'foo', slug: 'foo', paused: false)]; From a5fec40f9f671321e98b5019444805443f746001 Mon Sep 17 00:00:00 2001 From: Remi Rousselet Date: Thu, 1 Aug 2024 15:05:39 +0200 Subject: [PATCH 7/7] Remove unimplemented endpoint --- packages/globe_cli/lib/src/graphql/organization.graphql | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/globe_cli/lib/src/graphql/organization.graphql b/packages/globe_cli/lib/src/graphql/organization.graphql index cd1b8fb..c69a03b 100644 --- a/packages/globe_cli/lib/src/graphql/organization.graphql +++ b/packages/globe_cli/lib/src/graphql/organization.graphql @@ -28,5 +28,4 @@ type Organization { extend type Query { organization(slug: String!): Organization - organizations: [Organization!] }