Skip to content

Commit 30dd3ca

Browse files
Merge pull request #317 from daostack/CM-265-common-create-validation
CM-265: Create Common - Tagline and About fields should be not required
2 parents fbb8992 + 1d46730 commit 30dd3ca

File tree

7 files changed

+73
-20
lines changed

7 files changed

+73
-20
lines changed

packages/firebase/__tests__/funtions/__snapshots__/common.test.ts.snap

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ exports[`Common Related Cloud Functions Common Creation should fail validation o
44
Array [
55
"You must provide a valid URL",
66
"image is a required field",
7-
"byline is a required field",
87
"contributionAmount is a required field",
98
]
109
`;

packages/firebase/functions/src/common/business/createCommon.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ const createCommonDataValidationScheme = yup.object({
2323
})
2424
.required(),
2525

26-
byline: yup.string().min(10).required(),
26+
byline: yup.string().min(10),
2727

28-
description: yup.string().required(),
28+
description: yup.string(),
2929

3030
contributionAmount: yup.number().min(0).required(),
3131

packages/firebase/functions/src/core/graph/generated/schema.graphql

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22
### Do not make changes to this file directly
33

44

5+
type Amount {
6+
amount: String
7+
currency: String
8+
}
9+
10+
type Balance {
11+
available: Amount
12+
unsettled: Amount
13+
}
14+
515
type Card {
616
circleCardId: ID!
717

@@ -83,9 +93,7 @@ type CommonMember {
8393
}
8494

8595
type CommonMetadata {
86-
byline: String!
8796
contributionType: CommonContributionType
88-
description: String!
8997
founderId: String!
9098
minFeeToJoin: Int!
9199
}
@@ -183,6 +191,7 @@ enum IntentionType {
183191
}
184192

185193
type Mutation {
194+
approvePayout(index: Int!, payoutId: ID!, token: String!): Boolean
186195
createIntention(input: CreateIntentionInput!): Intention
187196
executePayouts(input: ExecutePayoutInput!): Payout
188197

@@ -193,7 +202,11 @@ type Mutation {
193202
"""The common id to refresh"""
194203
commonId: ID!
195204
): Int
196-
updatePaymentData(id: ID!, trackId: ID = "f4a15b1d-19f7-4d66-a0d2-95a504f6c2c4"): Boolean
205+
updatePaymentData(id: ID!, trackId: ID = "919d4c7d-1a93-40da-a3c1-59eac6f18ba2"): Boolean
206+
updatePaymentsCommonId: Boolean
207+
updatePayoutStatus(payoutId: ID!): Boolean
208+
updatePayoutsStatus: Boolean
209+
whitelistCommon(commonId: ID!): Boolean
197210
}
198211

199212
type Payment {
@@ -369,6 +382,7 @@ enum ProposalVoteOutcome {
369382
}
370383

371384
type Query {
385+
balance: Balance
372386
common(
373387
"""The ID of the common, that you want to retrieve"""
374388
commonId: ID!

packages/firebase/functions/src/core/graph/generated/schema.types.ts

Lines changed: 50 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
*/
55

66

7-
import { IRequestContext } from "./../../../core"
8-
import { core } from "nexus"
7+
import { IRequestContext } from './../../../core';
8+
import { core } from 'nexus';
9+
910
declare global {
1011
interface NexusGenCustomInputMethods<TypeName extends string> {
1112
date<FieldName extends string>(fieldName: FieldName, opts?: core.CommonInputFieldConfig<TypeName, FieldName>): void // "Date";
@@ -61,6 +62,14 @@ export interface NexusGenScalars {
6162
}
6263

6364
export interface NexusGenObjects {
65+
Amount: { // root type
66+
amount?: string | null; // String
67+
currency?: string | null; // String
68+
}
69+
Balance: { // root type
70+
available?: NexusGenRootTypes['Amount'] | null; // Amount
71+
unsettled?: NexusGenRootTypes['Amount'] | null; // Amount
72+
}
6473
Card: { // root type
6574
circleCardId: string; // ID!
6675
createdAt: NexusGenScalars['Date']; // Date!
@@ -98,9 +107,7 @@ export interface NexusGenObjects {
98107
userId: string; // ID!
99108
}
100109
CommonMetadata: { // root type
101-
byline: string; // String!
102110
contributionType?: NexusGenEnums['CommonContributionType'] | null; // CommonContributionType
103-
description: string; // String!
104111
founderId: string; // String!
105112
minFeeToJoin: number; // Int!
106113
}
@@ -266,6 +273,14 @@ export type NexusGenRootTypes = NexusGenObjects
266273
export type NexusGenAllTypes = NexusGenRootTypes & NexusGenScalars & NexusGenEnums
267274

268275
export interface NexusGenFieldTypes {
276+
Amount: { // field return type
277+
amount: string | null; // String
278+
currency: string | null; // String
279+
}
280+
Balance: { // field return type
281+
available: NexusGenRootTypes['Amount'] | null; // Amount
282+
unsettled: NexusGenRootTypes['Amount'] | null; // Amount
283+
}
269284
Card: { // field return type
270285
circleCardId: string; // ID!
271286
createdAt: NexusGenScalars['Date']; // Date!
@@ -310,9 +325,7 @@ export interface NexusGenFieldTypes {
310325
userId: string; // ID!
311326
}
312327
CommonMetadata: { // field return type
313-
byline: string; // String!
314328
contributionType: NexusGenEnums['CommonContributionType'] | null; // CommonContributionType
315-
description: string; // String!
316329
founderId: string; // String!
317330
minFeeToJoin: number; // Int!
318331
}
@@ -333,10 +346,15 @@ export interface NexusGenFieldTypes {
333346
updatedAt: NexusGenScalars['Date']; // Date!
334347
}
335348
Mutation: { // field return type
349+
approvePayout: boolean | null; // Boolean
336350
createIntention: NexusGenRootTypes['Intention'] | null; // Intention
337351
executePayouts: NexusGenRootTypes['Payout'] | null; // Payout
338352
refreshCommonMembers: number | null; // Int
339353
updatePaymentData: boolean | null; // Boolean
354+
updatePaymentsCommonId: boolean | null; // Boolean
355+
updatePayoutStatus: boolean | null; // Boolean
356+
updatePayoutsStatus: boolean | null; // Boolean
357+
whitelistCommon: boolean | null; // Boolean
340358
}
341359
Payment: { // field return type
342360
amount: NexusGenRootTypes['PaymentAmount']; // PaymentAmount!
@@ -425,6 +443,7 @@ export interface NexusGenFieldTypes {
425443
voterId: string; // ID!
426444
}
427445
Query: { // field return type
446+
balance: NexusGenRootTypes['Balance'] | null; // Balance
428447
common: NexusGenRootTypes['Common'] | null; // Common
429448
commons: Array<NexusGenRootTypes['Common'] | null> | null; // [Common]
430449
event: NexusGenRootTypes['Event'] | null; // Event
@@ -509,6 +528,14 @@ export interface NexusGenFieldTypes {
509528
}
510529

511530
export interface NexusGenFieldTypeNames {
531+
Amount: { // field return type name
532+
amount: 'String'
533+
currency: 'String'
534+
}
535+
Balance: { // field return type name
536+
available: 'Amount'
537+
unsettled: 'Amount'
538+
}
512539
Card: { // field return type name
513540
circleCardId: 'ID'
514541
createdAt: 'Date'
@@ -553,9 +580,7 @@ export interface NexusGenFieldTypeNames {
553580
userId: 'ID'
554581
}
555582
CommonMetadata: { // field return type name
556-
byline: 'String'
557583
contributionType: 'CommonContributionType'
558-
description: 'String'
559584
founderId: 'String'
560585
minFeeToJoin: 'Int'
561586
}
@@ -576,10 +601,15 @@ export interface NexusGenFieldTypeNames {
576601
updatedAt: 'Date'
577602
}
578603
Mutation: { // field return type name
604+
approvePayout: 'Boolean'
579605
createIntention: 'Intention'
580606
executePayouts: 'Payout'
581607
refreshCommonMembers: 'Int'
582608
updatePaymentData: 'Boolean'
609+
updatePaymentsCommonId: 'Boolean'
610+
updatePayoutStatus: 'Boolean'
611+
updatePayoutsStatus: 'Boolean'
612+
whitelistCommon: 'Boolean'
583613
}
584614
Payment: { // field return type name
585615
amount: 'PaymentAmount'
@@ -668,6 +698,7 @@ export interface NexusGenFieldTypeNames {
668698
voterId: 'ID'
669699
}
670700
Query: { // field return type name
701+
balance: 'Balance'
671702
common: 'Common'
672703
commons: 'Common'
673704
event: 'Event'
@@ -761,6 +792,11 @@ export interface NexusGenArgTypes {
761792
}
762793
}
763794
Mutation: {
795+
approvePayout: { // args
796+
index: number; // Int!
797+
payoutId: string; // ID!
798+
token: string; // String!
799+
}
764800
createIntention: { // args
765801
input: NexusGenInputs['CreateIntentionInput']; // CreateIntentionInput!
766802
}
@@ -774,6 +810,12 @@ export interface NexusGenArgTypes {
774810
id: string; // ID!
775811
trackId: string | null; // ID
776812
}
813+
updatePayoutStatus: { // args
814+
payoutId: string; // ID!
815+
}
816+
whitelistCommon: { // args
817+
commonId: string; // ID!
818+
}
777819
}
778820
Query: {
779821
common: { // args

packages/firebase/functions/src/core/graph/schema/commons/types/Common.type.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ export const CommonType = objectType({
2424

2525
t.nonNull.int('balance', {
2626
description: 'The currently available funds of the common',
27-
resolve: (root: ICommonEntity) => Math.round(root.balance),
27+
resolve: (root) => Math.round((root as ICommonEntity).balance)
2828
});
2929

3030
t.nonNull.int('raised', {
3131
description: 'The total amount of money, raised by the common',
32-
resolve: (root: ICommonEntity) => Math.round(root.raised),
32+
resolve: (root) => Math.round((root as ICommonEntity).raised)
3333
});
3434

3535
t.nonNull.field('metadata', {

packages/firebase/functions/src/core/graph/schema/commons/types/CommonMetadata.type.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import { CommonContributionTypeEnum } from '../enums/CommonContributionType.enum
55
export const CommonMetadataType = objectType({
66
name: 'CommonMetadata',
77
definition(t) {
8-
t.nonNull.string('byline');
9-
t.nonNull.string('description');
108
t.nonNull.string('founderId');
119
t.nonNull.int('minFeeToJoin');
1210

packages/types/src/entities/ICommonEntity.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ export interface ICommonLink {
8585
}
8686

8787
export interface ICommonMetadata {
88-
byline: string;
89-
description: string;
88+
byline?: string;
89+
description?: string;
9090

9191
/**
9292
* The id of the user, who created the common

0 commit comments

Comments
 (0)