Skip to content

The open alternative to Salesforce, designed for AI.

Scope server with workspace (#157)

Charles Bochet3674365e6fa6
diff --git a/front/src/generated/graphql.tsx b/front/src/generated/graphql.tsx
index 3cc0cbc216d..5f23a619668 100644
--- a/front/src/generated/graphql.tsx
+++ b/front/src/generated/graphql.tsx
@@ -67,30 +67,6 @@ export type CompanyCreateInput = {
updatedAt?: InputMaybe<Scalars['DateTime']>;
};
-export type CompanyCreateManyWorkspaceInput = {
- accountOwnerId?: InputMaybe<Scalars['String']>;
- address: Scalars['String'];
- createdAt?: InputMaybe<Scalars['DateTime']>;
- deletedAt?: InputMaybe<Scalars['DateTime']>;
- domainName: Scalars['String'];
- employees?: InputMaybe<Scalars['Int']>;
- id: Scalars['String'];
- name: Scalars['String'];
- updatedAt?: InputMaybe<Scalars['DateTime']>;
-};
-
-export type CompanyCreateManyWorkspaceInputEnvelope = {
- data: Array<CompanyCreateManyWorkspaceInput>;
- skipDuplicates?: InputMaybe<Scalars['Boolean']>;
-};
-
-export type CompanyCreateNestedManyWithoutWorkspaceInput = {
- connect?: InputMaybe<Array<CompanyWhereUniqueInput>>;
- connectOrCreate?: InputMaybe<Array<CompanyCreateOrConnectWithoutWorkspaceInput>>;
- create?: InputMaybe<Array<CompanyCreateWithoutWorkspaceInput>>;
- createMany?: InputMaybe<CompanyCreateManyWorkspaceInputEnvelope>;
-};
-
export type CompanyCreateNestedOneWithoutPeopleInput = {
connect?: InputMaybe<CompanyWhereUniqueInput>;
connectOrCreate?: InputMaybe<CompanyCreateOrConnectWithoutPeopleInput>;
@@ -102,11 +78,6 @@ export type CompanyCreateOrConnectWithoutPeopleInput = {
where: CompanyWhereUniqueInput;
};
-export type CompanyCreateOrConnectWithoutWorkspaceInput = {
- create: CompanyCreateWithoutWorkspaceInput;
- where: CompanyWhereUniqueInput;
-};
-
export type CompanyCreateWithoutPeopleInput = {
accountOwner?: InputMaybe<UserCreateNestedOneWithoutCompaniesInput>;
address: Scalars['String'];
@@ -119,19 +90,6 @@ export type CompanyCreateWithoutPeopleInput = {
updatedAt?: InputMaybe<Scalars['DateTime']>;
};
-export type CompanyCreateWithoutWorkspaceInput = {
- accountOwner?: InputMaybe<UserCreateNestedOneWithoutCompaniesInput>;
- address: Scalars['String'];
- createdAt?: InputMaybe<Scalars['DateTime']>;
- deletedAt?: InputMaybe<Scalars['DateTime']>;
- domainName: Scalars['String'];
- employees?: InputMaybe<Scalars['Int']>;
- id: Scalars['String'];
- name: Scalars['String'];
- people?: InputMaybe<PersonCreateNestedManyWithoutCompanyInput>;
- updatedAt?: InputMaybe<Scalars['DateTime']>;
-};
-
export type CompanyListRelationFilter = {
every?: InputMaybe<CompanyWhereInput>;
none?: InputMaybe<CompanyWhereInput>;
@@ -174,21 +132,6 @@ export enum CompanyScalarFieldEnum {
WorkspaceId = 'workspaceId'
}
-export type CompanyScalarWhereInput = {
- AND?: InputMaybe<Array<CompanyScalarWhereInput>>;
- NOT?: InputMaybe<Array<CompanyScalarWhereInput>>;
- OR?: InputMaybe<Array<CompanyScalarWhereInput>>;
- accountOwnerId?: InputMaybe<StringNullableFilter>;
- address?: InputMaybe<StringFilter>;
- createdAt?: InputMaybe<DateTimeFilter>;
- deletedAt?: InputMaybe<DateTimeNullableFilter>;
- domainName?: InputMaybe<StringFilter>;
- employees?: InputMaybe<IntNullableFilter>;
- id?: InputMaybe<StringFilter>;
- name?: InputMaybe<StringFilter>;
- updatedAt?: InputMaybe<DateTimeFilter>;
-};
-
export type CompanyUpdateInput = {
accountOwner?: InputMaybe<UserUpdateOneWithoutCompaniesNestedInput>;
address?: InputMaybe<StringFieldUpdateOperationsInput>;
@@ -202,36 +145,6 @@ export type CompanyUpdateInput = {
updatedAt?: InputMaybe<DateTimeFieldUpdateOperationsInput>;
};
-export type CompanyUpdateManyMutationInput = {
- address?: InputMaybe<StringFieldUpdateOperationsInput>;
- createdAt?: InputMaybe<DateTimeFieldUpdateOperationsInput>;
- deletedAt?: InputMaybe<NullableDateTimeFieldUpdateOperationsInput>;
- domainName?: InputMaybe<StringFieldUpdateOperationsInput>;
- employees?: InputMaybe<NullableIntFieldUpdateOperationsInput>;
- id?: InputMaybe<StringFieldUpdateOperationsInput>;
- name?: InputMaybe<StringFieldUpdateOperationsInput>;
- updatedAt?: InputMaybe<DateTimeFieldUpdateOperationsInput>;
-};
-
-export type CompanyUpdateManyWithWhereWithoutWorkspaceInput = {
- data: CompanyUpdateManyMutationInput;
- where: CompanyScalarWhereInput;
-};
-
-export type CompanyUpdateManyWithoutWorkspaceNestedInput = {
- connect?: InputMaybe<Array<CompanyWhereUniqueInput>>;
- connectOrCreate?: InputMaybe<Array<CompanyCreateOrConnectWithoutWorkspaceInput>>;
- create?: InputMaybe<Array<CompanyCreateWithoutWorkspaceInput>>;
- createMany?: InputMaybe<CompanyCreateManyWorkspaceInputEnvelope>;
- delete?: InputMaybe<Array<CompanyWhereUniqueInput>>;
- deleteMany?: InputMaybe<Array<CompanyScalarWhereInput>>;
- disconnect?: InputMaybe<Array<CompanyWhereUniqueInput>>;
- set?: InputMaybe<Array<CompanyWhereUniqueInput>>;
- update?: InputMaybe<Array<CompanyUpdateWithWhereUniqueWithoutWorkspaceInput>>;
- updateMany?: InputMaybe<Array<CompanyUpdateManyWithWhereWithoutWorkspaceInput>>;
- upsert?: InputMaybe<Array<CompanyUpsertWithWhereUniqueWithoutWorkspaceInput>>;
-};
-
export type CompanyUpdateOneWithoutPeopleNestedInput = {
connect?: InputMaybe<CompanyWhereUniqueInput>;
connectOrCreate?: InputMaybe<CompanyCreateOrConnectWithoutPeopleInput>;
@@ -242,11 +155,6 @@ export type CompanyUpdateOneWithoutPeopleNestedInput = {
upsert?: InputMaybe<CompanyUpsertWithoutPeopleInput>;
};
-export type CompanyUpdateWithWhereUniqueWithoutWorkspaceInput = {
- data: CompanyUpdateWithoutWorkspaceInput;
- where: CompanyWhereUniqueInput;
-};
-
export type CompanyUpdateWithoutPeopleInput = {
accountOwner?: InputMaybe<UserUpdateOneWithoutCompaniesNestedInput>;
address?: InputMaybe<StringFieldUpdateOperationsInput>;
@@ -259,25 +167,6 @@ export type CompanyUpdateWithoutPeopleInput = {
updatedAt?: InputMaybe<DateTimeFieldUpdateOperationsInput>;
};
-export type CompanyUpdateWithoutWorkspaceInput = {
- accountOwner?: InputMaybe<UserUpdateOneWithoutCompaniesNestedInput>;
- address?: InputMaybe<StringFieldUpdateOperationsInput>;
- createdAt?: InputMaybe<DateTimeFieldUpdateOperationsInput>;
- deletedAt?: InputMaybe<NullableDateTimeFieldUpdateOperationsInput>;
- domainName?: InputMaybe<StringFieldUpdateOperationsInput>;
- employees?: InputMaybe<NullableIntFieldUpdateOperationsInput>;
- id?: InputMaybe<StringFieldUpdateOperationsInput>;
- name?: InputMaybe<StringFieldUpdateOperationsInput>;
- people?: InputMaybe<PersonUpdateManyWithoutCompanyNestedInput>;
- updatedAt?: InputMaybe<DateTimeFieldUpdateOperationsInput>;
-};
-
-export type CompanyUpsertWithWhereUniqueWithoutWorkspaceInput = {
- create: CompanyCreateWithoutWorkspaceInput;
- update: CompanyUpdateWithoutWorkspaceInput;
- where: CompanyWhereUniqueInput;
-};
-
export type CompanyUpsertWithoutPeopleInput = {
create: CompanyCreateWithoutPeopleInput;
update: CompanyUpdateWithoutPeopleInput;
@@ -363,7 +252,6 @@ export type Mutation = {
createOnePerson: Person;
deleteManyCompany: AffectedRows;
deleteManyPerson: AffectedRows;
- deleteOneCompany?: Maybe<Company>;
updateOneCompany?: Maybe<Company>;
updateOnePerson?: Maybe<Person>;
};
@@ -389,11 +277,6 @@ export type MutationDeleteManyPersonArgs = {
};
-export type MutationDeleteOneCompanyArgs = {
- where: CompanyWhereUniqueInput;
-};
-
-
export type MutationUpdateOneCompanyArgs = {
data: CompanyUpdateInput;
where: CompanyWhereUniqueInput;
@@ -534,24 +417,6 @@ export type PersonCreateManyCompanyInputEnvelope = {
skipDuplicates?: InputMaybe<Scalars['Boolean']>;
};
-export type PersonCreateManyWorkspaceInput = {
- city: Scalars['String'];
- companyId?: InputMaybe<Scalars['String']>;
- createdAt?: InputMaybe<Scalars['DateTime']>;
- deletedAt?: InputMaybe<Scalars['DateTime']>;
- email: Scalars['String'];
- firstname: Scalars['String'];
- id: Scalars['String'];
- lastname: Scalars['String'];
- phone: Scalars['String'];
- updatedAt?: InputMaybe<Scalars['DateTime']>;
-};
-
-export type PersonCreateManyWorkspaceInputEnvelope = {
- data: Array<PersonCreateManyWorkspaceInput>;
- skipDuplicates?: InputMaybe<Scalars['Boolean']>;
-};
-
export type PersonCreateNestedManyWithoutCompanyInput = {
connect?: InputMaybe<Array<PersonWhereUniqueInput>>;
connectOrCreate?: InputMaybe<Array<PersonCreateOrConnectWithoutCompanyInput>>;
@@ -559,23 +424,11 @@ export type PersonCreateNestedManyWithoutCompanyInput = {
createMany?: InputMaybe<PersonCreateManyCompanyInputEnvelope>;
};
-export type PersonCreateNestedManyWithoutWorkspaceInput = {
- connect?: InputMaybe<Array<PersonWhereUniqueInput>>;
- connectOrCreate?: InputMaybe<Array<PersonCreateOrConnectWithoutWorkspaceInput>>;
- create?: InputMaybe<Array<PersonCreateWithoutWorkspaceInput>>;
- createMany?: InputMaybe<PersonCreateManyWorkspaceInputEnvelope>;
-};
-
export type PersonCreateOrConnectWithoutCompanyInput = {
create: PersonCreateWithoutCompanyInput;
where: PersonWhereUniqueInput;
};
-export type PersonCreateOrConnectWithoutWorkspaceInput = {
- create: PersonCreateWithoutWorkspaceInput;
- where: PersonWhereUniqueInput;
-};
-
export type PersonCreateWithoutCompanyInput = {
city: Scalars['String'];
createdAt?: InputMaybe<Scalars['DateTime']>;
@@ -588,19 +441,6 @@ export type PersonCreateWithoutCompanyInput = {
updatedAt?: InputMaybe<Scalars['DateTime']>;
};
-export type PersonCreateWithoutWorkspaceInput = {
- city: Scalars['String'];
- company?: InputMaybe<CompanyCreateNestedOneWithoutPeopleInput>;
- createdAt?: InputMaybe<Scalars['DateTime']>;
- deletedAt?: InputMaybe<Scalars['DateTime']>;
- email: Scalars['String'];
- firstname: Scalars['String'];
- id: Scalars['String'];
- lastname: Scalars['String'];
- phone: Scalars['String'];
- updatedAt?: InputMaybe<Scalars['DateTime']>;
-};
-
export type PersonListRelationFilter = {
every?: InputMaybe<PersonWhereInput>;
none?: InputMaybe<PersonWhereInput>;
@@ -685,11 +525,6 @@ export type PersonUpdateManyWithWhereWithoutCompanyInput = {
where: PersonScalarWhereInput;
};
-export type PersonUpdateManyWithWhereWithoutWorkspaceInput = {
- data: PersonUpdateManyMutationInput;
- where: PersonScalarWhereInput;
-};
-
export type PersonUpdateManyWithoutCompanyNestedInput = {
connect?: InputMaybe<Array<PersonWhereUniqueInput>>;
connectOrCreate?: InputMaybe<Array<PersonCreateOrConnectWithoutCompanyInput>>;
@@ -704,30 +539,11 @@ export type PersonUpdateManyWithoutCompanyNestedInput = {
upsert?: InputMaybe<Array<PersonUpsertWithWhereUniqueWithoutCompanyInput>>;
};
-export type PersonUpdateManyWithoutWorkspaceNestedInput = {
- connect?: InputMaybe<Array<PersonWhereUniqueInput>>;
- connectOrCreate?: InputMaybe<Array<PersonCreateOrConnectWithoutWorkspaceInput>>;
- create?: InputMaybe<Array<PersonCreateWithoutWorkspaceInput>>;
- createMany?: InputMaybe<PersonCreateManyWorkspaceInputEnvelope>;
- delete?: InputMaybe<Array<PersonWhereUniqueInput>>;
- deleteMany?: InputMaybe<Array<PersonScalarWhereInput>>;
- disconnect?: InputMaybe<Array<PersonWhereUniqueInput>>;
- set?: InputMaybe<Array<PersonWhereUniqueInput>>;
- update?: InputMaybe<Array<PersonUpdateWithWhereUniqueWithoutWorkspaceInput>>;
- updateMany?: InputMaybe<Array<PersonUpdateManyWithWhereWithoutWorkspaceInput>>;
- upsert?: InputMaybe<Array<PersonUpsertWithWhereUniqueWithoutWorkspaceInput>>;
-};
-
export type PersonUpdateWithWhereUniqueWithoutCompanyInput = {
data: PersonUpdateWithoutCompanyInput;
where: PersonWhereUniqueInput;
};
-export type PersonUpdateWithWhereUniqueWithoutWorkspaceInput = {
- data: PersonUpdateWithoutWorkspaceInput;
- where: PersonWhereUniqueInput;
-};
-
export type PersonUpdateWithoutCompanyInput = {
city?: InputMaybe<StringFieldUpdateOperationsInput>;
createdAt?: InputMaybe<DateTimeFieldUpdateOperationsInput>;
@@ -740,31 +556,12 @@ export type PersonUpdateWithoutCompanyInput = {
updatedAt?: InputMaybe<DateTimeFieldUpdateOperationsInput>;
};
-export type PersonUpdateWithoutWorkspaceInput = {
- city?: InputMaybe<StringFieldUpdateOperationsInput>;
- company?: InputMaybe<CompanyUpdateOneWithoutPeopleNestedInput>;
- createdAt?: InputMaybe<DateTimeFieldUpdateOperationsInput>;
- deletedAt?: InputMaybe<NullableDateTimeFieldUpdateOperationsInput>;
- email?: InputMaybe<StringFieldUpdateOperationsInput>;
- firstname?: InputMaybe<StringFieldUpdateOperationsInput>;
- id?: InputMaybe<StringFieldUpdateOperationsInput>;
- lastname?: InputMaybe<StringFieldUpdateOperationsInput>;
- phone?: InputMaybe<StringFieldUpdateOperationsInput>;
- updatedAt?: InputMaybe<DateTimeFieldUpdateOperationsInput>;
-};
-
export type PersonUpsertWithWhereUniqueWithoutCompanyInput = {
create: PersonCreateWithoutCompanyInput;
update: PersonUpdateWithoutCompanyInput;
where: PersonWhereUniqueInput;
};
-export type PersonUpsertWithWhereUniqueWithoutWorkspaceInput = {
- create: PersonCreateWithoutWorkspaceInput;
- update: PersonUpdateWithoutWorkspaceInput;
- where: PersonWhereUniqueInput;
-};
-
export type PersonWhereInput = {
AND?: InputMaybe<Array<PersonWhereInput>>;
NOT?: InputMaybe<Array<PersonWhereInput>>;
@@ -788,14 +585,13 @@ export type PersonWhereUniqueInput = {
export type Query = {
__typename?: 'Query';
- companies: Array<Company>;
- people: Array<Person>;
- user: User;
- users: Array<User>;
+ findManyCompany: Array<Company>;
+ findManyPerson: Array<Person>;
+ findManyUser: Array<User>;
};
-export type QueryCompaniesArgs = {
+export type QueryFindManyCompanyArgs = {
cursor?: InputMaybe<CompanyWhereUniqueInput>;
distinct?: InputMaybe<Array<CompanyScalarFieldEnum>>;
orderBy?: InputMaybe<Array<CompanyOrderByWithRelationInput>>;
@@ -805,7 +601,7 @@ export type QueryCompaniesArgs = {
};
-export type QueryPeopleArgs = {
+export type QueryFindManyPersonArgs = {
cursor?: InputMaybe<PersonWhereUniqueInput>;
distinct?: InputMaybe<Array<PersonScalarFieldEnum>>;
orderBy?: InputMaybe<Array<PersonOrderByWithRelationInput>>;
@@ -815,12 +611,7 @@ export type QueryPeopleArgs = {
};
-export type QueryUserArgs = {
- where: UserWhereUniqueInput;
-};
-
-
-export type QueryUsersArgs = {
+export type QueryFindManyUserArgs = {
cursor?: InputMaybe<UserWhereUniqueInput>;
distinct?: InputMaybe<Array<UserScalarFieldEnum>>;
orderBy?: InputMaybe<Array<UserOrderByWithRelationInput>>;
@@ -1225,29 +1016,6 @@ export type WorkspaceCount = {
people: Scalars['Int'];
};
-export type WorkspaceCreateNestedOneWithoutWorkspaceMemberInput = {
- connect?: InputMaybe<WorkspaceWhereUniqueInput>;
- connectOrCreate?: InputMaybe<WorkspaceCreateOrConnectWithoutWorkspaceMemberInput>;
- create?: InputMaybe<WorkspaceCreateWithoutWorkspaceMemberInput>;
-};
-
-export type WorkspaceCreateOrConnectWithoutWorkspaceMemberInput = {
- create: WorkspaceCreateWithoutWorkspaceMemberInput;
- where: WorkspaceWhereUniqueInput;
-};
-
-export type WorkspaceCreateWithoutWorkspaceMemberInput = {
- companies?: InputMaybe<CompanyCreateNestedManyWithoutWorkspaceInput>;
- createdAt?: InputMaybe<Scalars['DateTime']>;
- deletedAt?: InputMaybe<Scalars['DateTime']>;
- displayName: Scalars['String'];
- domainName: Scalars['String'];
- id: Scalars['String'];
- logo?: InputMaybe<Scalars['String']>;
- people?: InputMaybe<PersonCreateNestedManyWithoutWorkspaceInput>;
- updatedAt?: InputMaybe<Scalars['DateTime']>;
-};
-
export type WorkspaceMember = {
__typename?: 'WorkspaceMember';
createdAt: Scalars['DateTime'];
@@ -1276,17 +1044,6 @@ export type WorkspaceMemberCreateWithoutUserInput = {
deletedAt?: InputMaybe<Scalars['DateTime']>;
id: Scalars['String'];
updatedAt?: InputMaybe<Scalars['DateTime']>;
- workspace: WorkspaceCreateNestedOneWithoutWorkspaceMemberInput;
-};
-
-export type WorkspaceMemberListRelationFilter = {
- every?: InputMaybe<WorkspaceMemberWhereInput>;
- none?: InputMaybe<WorkspaceMemberWhereInput>;
- some?: InputMaybe<WorkspaceMemberWhereInput>;
-};
-
-export type WorkspaceMemberOrderByRelationAggregateInput = {
- _count?: InputMaybe<SortOrder>;
};
export type WorkspaceMemberOrderByWithRelationInput = {
@@ -1296,8 +1053,6 @@ export type WorkspaceMemberOrderByWithRelationInput = {
updatedAt?: InputMaybe<SortOrder>;
user?: InputMaybe<UserOrderByWithRelationInput>;
userId?: InputMaybe<SortOrder>;
- workspace?: InputMaybe<WorkspaceOrderByWithRelationInput>;
- workspaceId?: InputMaybe<SortOrder>;
};
export type WorkspaceMemberRelationFilter = {
@@ -1320,7 +1075,6 @@ export type WorkspaceMemberUpdateWithoutUserInput = {
deletedAt?: InputMaybe<NullableDateTimeFieldUpdateOperationsInput>;
id?: InputMaybe<StringFieldUpdateOperationsInput>;
updatedAt?: InputMaybe<DateTimeFieldUpdateOperationsInput>;
- workspace?: InputMaybe<WorkspaceUpdateOneRequiredWithoutWorkspaceMemberNestedInput>;
};
export type WorkspaceMemberUpsertWithoutUserInput = {
@@ -1338,8 +1092,6 @@ export type WorkspaceMemberWhereInput = {
updatedAt?: InputMaybe<DateTimeFilter>;
user?: InputMaybe<UserRelationFilter>;
userId?: InputMaybe<StringFilter>;
- workspace?: InputMaybe<WorkspaceRelationFilter>;
- workspaceId?: InputMaybe<StringFilter>;
};
export type WorkspaceMemberWhereUniqueInput = {
@@ -1347,77 +1099,13 @@ export type WorkspaceMemberWhereUniqueInput = {
userId?: InputMaybe<Scalars['String']>;
};
-export type WorkspaceOrderByWithRelationInput = {
- WorkspaceMember?: InputMaybe<WorkspaceMemberOrderByRelationAggregateInput>;
- companies?: InputMaybe<CompanyOrderByRelationAggregateInput>;
- createdAt?: InputMaybe<SortOrder>;
- deletedAt?: InputMaybe<SortOrder>;
- displayName?: InputMaybe<SortOrder>;
- domainName?: InputMaybe<SortOrder>;
- id?: InputMaybe<SortOrder>;
- logo?: InputMaybe<SortOrder>;
- people?: InputMaybe<PersonOrderByRelationAggregateInput>;
- updatedAt?: InputMaybe<SortOrder>;
-};
-
-export type WorkspaceRelationFilter = {
- is?: InputMaybe<WorkspaceWhereInput>;
- isNot?: InputMaybe<WorkspaceWhereInput>;
-};
-
-export type WorkspaceUpdateOneRequiredWithoutWorkspaceMemberNestedInput = {
- connect?: InputMaybe<WorkspaceWhereUniqueInput>;
- connectOrCreate?: InputMaybe<WorkspaceCreateOrConnectWithoutWorkspaceMemberInput>;
- create?: InputMaybe<WorkspaceCreateWithoutWorkspaceMemberInput>;
- update?: InputMaybe<WorkspaceUpdateWithoutWorkspaceMemberInput>;
- upsert?: InputMaybe<WorkspaceUpsertWithoutWorkspaceMemberInput>;
-};
-
-export type WorkspaceUpdateWithoutWorkspaceMemberInput = {
- companies?: InputMaybe<CompanyUpdateManyWithoutWorkspaceNestedInput>;
- createdAt?: InputMaybe<DateTimeFieldUpdateOperationsInput>;
- deletedAt?: InputMaybe<NullableDateTimeFieldUpdateOperationsInput>;
- displayName?: InputMaybe<StringFieldUpdateOperationsInput>;
- domainName?: InputMaybe<StringFieldUpdateOperationsInput>;
- id?: InputMaybe<StringFieldUpdateOperationsInput>;
- logo?: InputMaybe<NullableStringFieldUpdateOperationsInput>;
- people?: InputMaybe<PersonUpdateManyWithoutWorkspaceNestedInput>;
- updatedAt?: InputMaybe<DateTimeFieldUpdateOperationsInput>;
-};
-
-export type WorkspaceUpsertWithoutWorkspaceMemberInput = {
- create: WorkspaceCreateWithoutWorkspaceMemberInput;
- update: WorkspaceUpdateWithoutWorkspaceMemberInput;
-};
-
-export type WorkspaceWhereInput = {
- AND?: InputMaybe<Array<WorkspaceWhereInput>>;
- NOT?: InputMaybe<Array<WorkspaceWhereInput>>;
- OR?: InputMaybe<Array<WorkspaceWhereInput>>;
- WorkspaceMember?: InputMaybe<WorkspaceMemberListRelationFilter>;
- companies?: InputMaybe<CompanyListRelationFilter>;
- createdAt?: InputMaybe<DateTimeFilter>;
- deletedAt?: InputMaybe<DateTimeNullableFilter>;
- displayName?: InputMaybe<StringFilter>;
- domainName?: InputMaybe<StringFilter>;
- id?: InputMaybe<StringFilter>;
- logo?: InputMaybe<StringNullableFilter>;
- people?: InputMaybe<PersonListRelationFilter>;
- updatedAt?: InputMaybe<DateTimeFilter>;
-};
-
-export type WorkspaceWhereUniqueInput = {
- domainName?: InputMaybe<Scalars['String']>;
- id?: InputMaybe<Scalars['String']>;
-};
-
export type GetCompaniesQueryVariables = Exact<{
orderBy?: InputMaybe<Array<CompanyOrderByWithRelationInput> | CompanyOrderByWithRelationInput>;
where?: InputMaybe<CompanyWhereInput>;
}>;
-export type GetCompaniesQuery = { __typename?: 'Query', companies: Array<{ __typename?: 'Company', id: string, domainName: string, name: string, createdAt: any, address: string, employees?: number | null, accountOwner?: { __typename?: 'User', id: string, email: string, displayName: string } | null }> };
+export type GetCompaniesQuery = { __typename?: 'Query', findManyCompany: Array<{ __typename?: 'Company', id: string, domainName: string, name: string, createdAt: any, address: string, employees?: number | null, accountOwner?: { __typename?: 'User', id: string, email: string, displayName: string } | null }> };
export type UpdateCompanyMutationVariables = Exact<{
id?: InputMaybe<Scalars['String']>;
@@ -1458,7 +1146,7 @@ export type GetPeopleQueryVariables = Exact<{
}>;
-export type GetPeopleQuery = { __typename?: 'Query', people: Array<{ __typename?: 'Person', id: string, phone: string, email: string, city: string, firstname: string, lastname: string, createdAt: any, company?: { __typename?: 'Company', id: string, name: string, domainName: string } | null }> };
+export type GetPeopleQuery = { __typename?: 'Query', findManyPerson: Array<{ __typename?: 'Person', id: string, phone: string, email: string, city: string, firstname: string, lastname: string, createdAt: any, company?: { __typename?: 'Company', id: string, name: string, domainName: string } | null }> };
export type UpdatePeopleMutationVariables = Exact<{
id?: InputMaybe<Scalars['String']>;
@@ -1513,39 +1201,39 @@ export type SearchUserQueryQuery = { __typename?: 'Query', searchResults: Array<
export type EmptyQueryQueryVariables = Exact<{ [key: string]: never; }>;
-export type EmptyQueryQuery = { __typename?: 'Query', users: Array<{ __typename?: 'User', id: string }> };
+export type EmptyQueryQuery = { __typename?: 'Query', findManyUser: Array<{ __typename?: 'User', id: string }> };
-export type SearchQueryQueryVariables = Exact<{
+export type SearchCompanyQueryQueryVariables = Exact<{
where?: InputMaybe<CompanyWhereInput>;
limit?: InputMaybe<Scalars['Int']>;
}>;
-export type SearchQueryQuery = { __typename?: 'Query', searchResults: Array<{ __typename?: 'Company', id: string, name: string, domainName: string }> };
+export type SearchCompanyQueryQuery = { __typename?: 'Query', searchResults: Array<{ __typename?: 'Company', id: string, name: string, domainName: string }> };
export type GetCurrentUserQueryVariables = Exact<{
uuid?: InputMaybe<Scalars['String']>;
}>;
-export type GetCurrentUserQuery = { __typename?: 'Query', users: Array<{ __typename?: 'User', id: string, email: string, displayName: string, workspaceMember?: { __typename?: 'WorkspaceMember', workspace: { __typename?: 'Workspace', id: string, domainName: string, displayName: string, logo?: string | null } } | null }> };
+export type GetCurrentUserQuery = { __typename?: 'Query', findManyUser: Array<{ __typename?: 'User', id: string, email: string, displayName: string, workspaceMember?: { __typename?: 'WorkspaceMember', workspace: { __typename?: 'Workspace', id: string, domainName: string, displayName: string, logo?: string | null } } | null }> };
export type GetUsersQueryVariables = Exact<{ [key: string]: never; }>;
-export type GetUsersQuery = { __typename?: 'Query', users: Array<{ __typename?: 'User', id: string }> };
+export type GetUsersQuery = { __typename?: 'Query', findManyUser: Array<{ __typename?: 'User', id: string }> };
export const GetCompaniesDocument = gql`
query GetCompanies($orderBy: [CompanyOrderByWithRelationInput!], $where: CompanyWhereInput) {
- companies(orderBy: $orderBy, where: $where) {
+ findManyCompany(orderBy: $orderBy, where: $where) {
id
domainName
name
createdAt
address
employees
- accountOwner: accountOwner {
+ accountOwner {
id
email
displayName
@@ -1714,7 +1402,7 @@ export type DeleteCompaniesMutationResult = Apollo.MutationResult<DeleteCompanie
export type DeleteCompaniesMutationOptions = Apollo.BaseMutationOptions<DeleteCompaniesMutation, DeleteCompaniesMutationVariables>;
export const GetPeopleDocument = gql`
query GetPeople($orderBy: [PersonOrderByWithRelationInput!], $where: PersonWhereInput, $limit: Int) {
- people(orderBy: $orderBy, where: $where, take: $limit) {
+ findManyPerson(orderBy: $orderBy, where: $where, take: $limit) {
id
phone
email
@@ -1901,7 +1589,7 @@ export type DeletePeopleMutationResult = Apollo.MutationResult<DeletePeopleMutat
export type DeletePeopleMutationOptions = Apollo.BaseMutationOptions<DeletePeopleMutation, DeletePeopleMutationVariables>;
export const SearchPeopleQueryDocument = gql`
query SearchPeopleQuery($where: PersonWhereInput, $limit: Int) {
- searchResults: people(where: $where, take: $limit) {
+ searchResults: findManyPerson(where: $where, take: $limit) {
id
phone
email
@@ -1943,7 +1631,7 @@ export type SearchPeopleQueryLazyQueryHookResult = ReturnType<typeof useSearchPe
export type SearchPeopleQueryQueryResult = Apollo.QueryResult<SearchPeopleQueryQuery, SearchPeopleQueryQueryVariables>;
export const SearchUserQueryDocument = gql`
query SearchUserQuery($where: UserWhereInput, $limit: Int) {
- searchResults: users(where: $where, take: $limit) {
+ searchResults: findManyUser(where: $where, take: $limit) {
id
email
displayName
@@ -1981,7 +1669,7 @@ export type SearchUserQueryLazyQueryHookResult = ReturnType<typeof useSearchUser
export type SearchUserQueryQueryResult = Apollo.QueryResult<SearchUserQueryQuery, SearchUserQueryQueryVariables>;
export const EmptyQueryDocument = gql`
query EmptyQuery {
- users {
+ findManyUser {
id
}
}
@@ -2013,47 +1701,47 @@ export function useEmptyQueryLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions
export type EmptyQueryQueryHookResult = ReturnType<typeof useEmptyQueryQuery>;
export type EmptyQueryLazyQueryHookResult = ReturnType<typeof useEmptyQueryLazyQuery>;
export type EmptyQueryQueryResult = Apollo.QueryResult<EmptyQueryQuery, EmptyQueryQueryVariables>;
-export const SearchQueryDocument = gql`
- query SearchQuery($where: CompanyWhereInput, $limit: Int) {
- searchResults: companies(where: $where, take: $limit) {
+export const SearchCompanyQueryDocument = gql`
+ query SearchCompanyQuery($where: CompanyWhereInput, $limit: Int) {
+ searchResults: findManyCompany(where: $where, take: $limit) {
id
name
- domainName: domainName
+ domainName
}
}
`;
/**
- * __useSearchQueryQuery__
+ * __useSearchCompanyQueryQuery__
*
- * To run a query within a React component, call `useSearchQueryQuery` and pass it any options that fit your needs.
- * When your component renders, `useSearchQueryQuery` returns an object from Apollo Client that contains loading, error, and data properties
+ * To run a query within a React component, call `useSearchCompanyQueryQuery` and pass it any options that fit your needs.
+ * When your component renders, `useSearchCompanyQueryQuery` returns an object from Apollo Client that contains loading, error, and data properties
* you can use to render your UI.
*
* @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
*
* @example
- * const { data, loading, error } = useSearchQueryQuery({
+ * const { data, loading, error } = useSearchCompanyQueryQuery({
* variables: {
* where: // value for 'where'
* limit: // value for 'limit'
* },
* });
*/
-export function useSearchQueryQuery(baseOptions?: Apollo.QueryHookOptions<SearchQueryQuery, SearchQueryQueryVariables>) {
+export function useSearchCompanyQueryQuery(baseOptions?: Apollo.QueryHookOptions<SearchCompanyQueryQuery, SearchCompanyQueryQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
- return Apollo.useQuery<SearchQueryQuery, SearchQueryQueryVariables>(SearchQueryDocument, options);
+ return Apollo.useQuery<SearchCompanyQueryQuery, SearchCompanyQueryQueryVariables>(SearchCompanyQueryDocument, options);
}
-export function useSearchQueryLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<SearchQueryQuery, SearchQueryQueryVariables>) {
+export function useSearchCompanyQueryLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<SearchCompanyQueryQuery, SearchCompanyQueryQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
- return Apollo.useLazyQuery<SearchQueryQuery, SearchQueryQueryVariables>(SearchQueryDocument, options);
+ return Apollo.useLazyQuery<SearchCompanyQueryQuery, SearchCompanyQueryQueryVariables>(SearchCompanyQueryDocument, options);
}
-export type SearchQueryQueryHookResult = ReturnType<typeof useSearchQueryQuery>;
-export type SearchQueryLazyQueryHookResult = ReturnType<typeof useSearchQueryLazyQuery>;
-export type SearchQueryQueryResult = Apollo.QueryResult<SearchQueryQuery, SearchQueryQueryVariables>;
+export type SearchCompanyQueryQueryHookResult = ReturnType<typeof useSearchCompanyQueryQuery>;
+export type SearchCompanyQueryLazyQueryHookResult = ReturnType<typeof useSearchCompanyQueryLazyQuery>;
+export type SearchCompanyQueryQueryResult = Apollo.QueryResult<SearchCompanyQueryQuery, SearchCompanyQueryQueryVariables>;
export const GetCurrentUserDocument = gql`
query getCurrentUser($uuid: String) {
- users(where: {id: {equals: $uuid}}) {
+ findManyUser(where: {id: {equals: $uuid}}) {
id
email
displayName
@@ -2098,7 +1786,7 @@ export type GetCurrentUserLazyQueryHookResult = ReturnType<typeof useGetCurrentU
export type GetCurrentUserQueryResult = Apollo.QueryResult<GetCurrentUserQuery, GetCurrentUserQueryVariables>;
export const GetUsersDocument = gql`
query getUsers {
- users {
+ findManyUser {
id
}
}
diff --git a/front/src/services/api/companies/select.ts b/front/src/services/api/companies/select.ts
index c0e24ab6607..2fb4f464a87 100644
--- a/front/src/services/api/companies/select.ts
+++ b/front/src/services/api/companies/select.ts
@@ -14,7 +14,7 @@ export const GET_COMPANIES = gql`
$orderBy: [CompanyOrderByWithRelationInput!]
$where: CompanyWhereInput
) {
- companies(orderBy: $orderBy, where: $where) {
+ companies: findManyCompany(orderBy: $orderBy, where: $where) {
id
domainName
name
diff --git a/front/src/services/api/people/select.ts b/front/src/services/api/people/select.ts
index 2d4ecca8d42..76942e3d3c9 100644
--- a/front/src/services/api/people/select.ts
+++ b/front/src/services/api/people/select.ts
@@ -15,7 +15,7 @@ export const GET_PEOPLE = gql`
$where: PersonWhereInput
$limit: Int
) {
- people(orderBy: $orderBy, where: $where, take: $limit) {
+ people: findManyPerson(orderBy: $orderBy, where: $where, take: $limit) {
id
phone
email
diff --git a/front/src/services/api/search/search.ts b/front/src/services/api/search/search.ts
index 8222cd307de..8fff8a8e98e 100644
--- a/front/src/services/api/search/search.ts
+++ b/front/src/services/api/search/search.ts
@@ -9,7 +9,7 @@ import { debounce } from '../../../modules/utils/debounce';
export const SEARCH_PEOPLE_QUERY = gql`
query SearchPeopleQuery($where: PersonWhereInput, $limit: Int) {
- searchResults: people(where: $where, take: $limit) {
+ searchResults: findManyPerson(where: $where, take: $limit) {
id
phone
email
@@ -23,7 +23,7 @@ export const SEARCH_PEOPLE_QUERY = gql`
export const SEARCH_USER_QUERY = gql`
query SearchUserQuery($where: UserWhereInput, $limit: Int) {
- searchResults: users(where: $where, take: $limit) {
+ searchResults: findManyUser(where: $where, take: $limit) {
id
email
displayName
@@ -33,7 +33,7 @@ export const SEARCH_USER_QUERY = gql`
// TODO: remove this query
export const EMPTY_QUERY = gql`
query EmptyQuery {
- users {
+ searchResults: findManyUser {
id
}
}
@@ -41,7 +41,7 @@ export const EMPTY_QUERY = gql`
export const SEARCH_COMPANY_QUERY = gql`
query SearchCompanyQuery($where: CompanyWhereInput, $limit: Int) {
- searchResults: companies(where: $where, take: $limit) {
+ searchResults: findManyCompany(where: $where, take: $limit) {
id
name
domainName
diff --git a/front/src/services/api/users/index.tsx b/front/src/services/api/users/index.tsx
index ec72ad0ce61..a896ecaaff7 100644
--- a/front/src/services/api/users/index.tsx
+++ b/front/src/services/api/users/index.tsx
@@ -3,7 +3,7 @@ import { GraphqlQueryUser } from '../../../interfaces/entities/user.interface';
export const GET_CURRENT_USER = gql`
query getCurrentUser($uuid: String) {
- users(where: { id: { equals: $uuid } }) {
+ users: findManyUser(where: { id: { equals: $uuid } }) {
id
email
displayName
diff --git a/front/src/services/api/users/test.tsx b/front/src/services/api/users/test.tsx
index 82891f10608..426098273cc 100644
--- a/front/src/services/api/users/test.tsx
+++ b/front/src/services/api/users/test.tsx
@@ -2,7 +2,7 @@ import { gql } from '@apollo/client';
export const GET_CURRENT_USER = gql`
query getUsers {
- users {
+ findManyUser {
id
}
}
diff --git a/front/src/testing/mock-data/index.ts b/front/src/testing/mock-data/index.ts
index e12bac6e27c..92b0be28e60 100644
--- a/front/src/testing/mock-data/index.ts
+++ b/front/src/testing/mock-data/index.ts
@@ -74,7 +74,6 @@ export function filterAndSortData<DataT>(
limit: number,
): Array<DataT> {
let filteredData = filterData<DataT>(data, where);
- console.log(filteredData);
if (orderBy) {
const firstOrderBy = orderBy[0];
diff --git a/server/src/api/@generated/refresh-token/refresh-token.model.ts b/server/src/api/@generated/refresh-token/refresh-token.model.ts
index e342d81ff14..776ac99899c 100644
--- a/server/src/api/@generated/refresh-token/refresh-token.model.ts
+++ b/server/src/api/@generated/refresh-token/refresh-token.model.ts
@@ -3,7 +3,7 @@ import { ObjectType } from '@nestjs/graphql';
import { ID } from '@nestjs/graphql';
import { User } from '../user/user.model';
-@ObjectType()
+@ObjectType({})
export class RefreshToken {
@Field(() => ID, { nullable: false })
id!: string;
diff --git a/server/src/api/@generated/workspace-member/workspace-member-count-aggregate.input.ts b/server/src/api/@generated/workspace-member/workspace-member-count-aggregate.input.ts
index 842fd4697ad..cda255b14f8 100644
--- a/server/src/api/@generated/workspace-member/workspace-member-count-aggregate.input.ts
+++ b/server/src/api/@generated/workspace-member/workspace-member-count-aggregate.input.ts
@@ -1,5 +1,6 @@
import { Field } from '@nestjs/graphql';
import { InputType } from '@nestjs/graphql';
+import { HideField } from '@nestjs/graphql';
@InputType()
export class WorkspaceMemberCountAggregateInput {
@@ -18,7 +19,7 @@ export class WorkspaceMemberCountAggregateInput {
@Field(() => Boolean, { nullable: true })
userId?: true;
- @Field(() => Boolean, { nullable: true })
+ @HideField()
workspaceId?: true;
@Field(() => Boolean, { nullable: true })
diff --git a/server/src/api/@generated/workspace-member/workspace-member-count-order-by-aggregate.input.ts b/server/src/api/@generated/workspace-member/workspace-member-count-order-by-aggregate.input.ts
index da648cfbb89..44ea07e760f 100644
--- a/server/src/api/@generated/workspace-member/workspace-member-count-order-by-aggregate.input.ts
+++ b/server/src/api/@generated/workspace-member/workspace-member-count-order-by-aggregate.input.ts
@@ -1,6 +1,7 @@
import { Field } from '@nestjs/graphql';
import { InputType } from '@nestjs/graphql';
import { SortOrder } from '../prisma/sort-order.enum';
+import { HideField } from '@nestjs/graphql';
@InputType()
export class WorkspaceMemberCountOrderByAggregateInput {
@@ -19,6 +20,6 @@ export class WorkspaceMemberCountOrderByAggregateInput {
@Field(() => SortOrder, { nullable: true })
userId?: keyof typeof SortOrder;
- @Field(() => SortOrder, { nullable: true })
+ @HideField()
workspaceId?: keyof typeof SortOrder;
}
diff --git a/server/src/api/@generated/workspace-member/workspace-member-create-many.input.ts b/server/src/api/@generated/workspace-member/workspace-member-create-many.input.ts
index 883c47e72b4..3c7aa2e98d0 100644
--- a/server/src/api/@generated/workspace-member/workspace-member-create-many.input.ts
+++ b/server/src/api/@generated/workspace-member/workspace-member-create-many.input.ts
@@ -1,5 +1,6 @@
import { Field } from '@nestjs/graphql';
import { InputType } from '@nestjs/graphql';
+import { HideField } from '@nestjs/graphql';
@InputType()
export class WorkspaceMemberCreateManyInput {
@@ -18,6 +19,6 @@ export class WorkspaceMemberCreateManyInput {
@Field(() => String, { nullable: false })
userId!: string;
- @Field(() => String, { nullable: false })
+ @HideField()
workspaceId!: string;
}
diff --git a/server/src/api/@generated/workspace-member/workspace-member-create-without-user.input.ts b/server/src/api/@generated/workspace-member/workspace-member-create-without-user.input.ts
index 8153880baf9..9ff23d08b63 100644
--- a/server/src/api/@generated/workspace-member/workspace-member-create-without-user.input.ts
+++ b/server/src/api/@generated/workspace-member/workspace-member-create-without-user.input.ts
@@ -1,6 +1,7 @@
import { Field } from '@nestjs/graphql';
import { InputType } from '@nestjs/graphql';
import { WorkspaceCreateNestedOneWithoutWorkspaceMemberInput } from '../workspace/workspace-create-nested-one-without-workspace-member.input';
+import { HideField } from '@nestjs/graphql';
@InputType()
export class WorkspaceMemberCreateWithoutUserInput {
@@ -16,8 +17,6 @@ export class WorkspaceMemberCreateWithoutUserInput {
@Field(() => Date, { nullable: true })
deletedAt?: Date | string;
- @Field(() => WorkspaceCreateNestedOneWithoutWorkspaceMemberInput, {
- nullable: false,
- })
+ @HideField()
workspace!: WorkspaceCreateNestedOneWithoutWorkspaceMemberInput;
}
diff --git a/server/src/api/@generated/workspace-member/workspace-member-create.input.ts b/server/src/api/@generated/workspace-member/workspace-member-create.input.ts
index 6abea0d7bd0..5bff173c393 100644
--- a/server/src/api/@generated/workspace-member/workspace-member-create.input.ts
+++ b/server/src/api/@generated/workspace-member/workspace-member-create.input.ts
@@ -2,6 +2,7 @@ import { Field } from '@nestjs/graphql';
import { InputType } from '@nestjs/graphql';
import { UserCreateNestedOneWithoutWorkspaceMemberInput } from '../user/user-create-nested-one-without-workspace-member.input';
import { WorkspaceCreateNestedOneWithoutWorkspaceMemberInput } from '../workspace/workspace-create-nested-one-without-workspace-member.input';
+import { HideField } from '@nestjs/graphql';
@InputType()
export class WorkspaceMemberCreateInput {
@@ -22,8 +23,6 @@ export class WorkspaceMemberCreateInput {
})
user!: UserCreateNestedOneWithoutWorkspaceMemberInput;
- @Field(() => WorkspaceCreateNestedOneWithoutWorkspaceMemberInput, {
- nullable: false,
- })
+ @HideField()
workspace!: WorkspaceCreateNestedOneWithoutWorkspaceMemberInput;
}
diff --git a/server/src/api/@generated/workspace-member/workspace-member-max-aggregate.input.ts b/server/src/api/@generated/workspace-member/workspace-member-max-aggregate.input.ts
index d4384d000d5..7b0a747115d 100644
--- a/server/src/api/@generated/workspace-member/workspace-member-max-aggregate.input.ts
+++ b/server/src/api/@generated/workspace-member/workspace-member-max-aggregate.input.ts
@@ -1,5 +1,6 @@
import { Field } from '@nestjs/graphql';
import { InputType } from '@nestjs/graphql';
+import { HideField } from '@nestjs/graphql';
@InputType()
export class WorkspaceMemberMaxAggregateInput {
@@ -18,6 +19,6 @@ export class WorkspaceMemberMaxAggregateInput {
@Field(() => Boolean, { nullable: true })
userId?: true;
- @Field(() => Boolean, { nullable: true })
+ @HideField()
workspaceId?: true;
}
diff --git a/server/src/api/@generated/workspace-member/workspace-member-max-order-by-aggregate.input.ts b/server/src/api/@generated/workspace-member/workspace-member-max-order-by-aggregate.input.ts
index 6e66c98a8ba..2e308d0ffcf 100644
--- a/server/src/api/@generated/workspace-member/workspace-member-max-order-by-aggregate.input.ts
+++ b/server/src/api/@generated/workspace-member/workspace-member-max-order-by-aggregate.input.ts
@@ -1,6 +1,7 @@
import { Field } from '@nestjs/graphql';
import { InputType } from '@nestjs/graphql';
import { SortOrder } from '../prisma/sort-order.enum';
+import { HideField } from '@nestjs/graphql';
@InputType()
export class WorkspaceMemberMaxOrderByAggregateInput {
@@ -19,6 +20,6 @@ export class WorkspaceMemberMaxOrderByAggregateInput {
@Field(() => SortOrder, { nullable: true })
userId?: keyof typeof SortOrder;
- @Field(() => SortOrder, { nullable: true })
+ @HideField()
workspaceId?: keyof typeof SortOrder;
}
diff --git a/server/src/api/@generated/workspace-member/workspace-member-min-aggregate.input.ts b/server/src/api/@generated/workspace-member/workspace-member-min-aggregate.input.ts
index 4be957eff7e..4d50678815f 100644
--- a/server/src/api/@generated/workspace-member/workspace-member-min-aggregate.input.ts
+++ b/server/src/api/@generated/workspace-member/workspace-member-min-aggregate.input.ts
@@ -1,5 +1,6 @@
import { Field } from '@nestjs/graphql';
import { InputType } from '@nestjs/graphql';
+import { HideField } from '@nestjs/graphql';
@InputType()
export class WorkspaceMemberMinAggregateInput {
@@ -18,6 +19,6 @@ export class WorkspaceMemberMinAggregateInput {
@Field(() => Boolean, { nullable: true })
userId?: true;
- @Field(() => Boolean, { nullable: true })
+ @HideField()
workspaceId?: true;
}
diff --git a/server/src/api/@generated/workspace-member/workspace-member-min-order-by-aggregate.input.ts b/server/src/api/@generated/workspace-member/workspace-member-min-order-by-aggregate.input.ts
index e02613c4f93..75dfbd04364 100644
--- a/server/src/api/@generated/workspace-member/workspace-member-min-order-by-aggregate.input.ts
+++ b/server/src/api/@generated/workspace-member/workspace-member-min-order-by-aggregate.input.ts
@@ -1,6 +1,7 @@
import { Field } from '@nestjs/graphql';
import { InputType } from '@nestjs/graphql';
import { SortOrder } from '../prisma/sort-order.enum';
+import { HideField } from '@nestjs/graphql';
@InputType()
export class WorkspaceMemberMinOrderByAggregateInput {
@@ -19,6 +20,6 @@ export class WorkspaceMemberMinOrderByAggregateInput {
@Field(() => SortOrder, { nullable: true })
userId?: keyof typeof SortOrder;
- @Field(() => SortOrder, { nullable: true })
+ @HideField()
workspaceId?: keyof typeof SortOrder;
}
diff --git a/server/src/api/@generated/workspace-member/workspace-member-order-by-with-aggregation.input.ts b/server/src/api/@generated/workspace-member/workspace-member-order-by-with-aggregation.input.ts
index c83d18d6d2a..4281f1efd7c 100644
--- a/server/src/api/@generated/workspace-member/workspace-member-order-by-with-aggregation.input.ts
+++ b/server/src/api/@generated/workspace-member/workspace-member-order-by-with-aggregation.input.ts
@@ -1,6 +1,7 @@
import { Field } from '@nestjs/graphql';
import { InputType } from '@nestjs/graphql';
import { SortOrder } from '../prisma/sort-order.enum';
+import { HideField } from '@nestjs/graphql';
import { WorkspaceMemberCountOrderByAggregateInput } from './workspace-member-count-order-by-aggregate.input';
import { WorkspaceMemberMaxOrderByAggregateInput } from './workspace-member-max-order-by-aggregate.input';
import { WorkspaceMemberMinOrderByAggregateInput } from './workspace-member-min-order-by-aggregate.input';
@@ -22,7 +23,7 @@ export class WorkspaceMemberOrderByWithAggregationInput {
@Field(() => SortOrder, { nullable: true })
userId?: keyof typeof SortOrder;
- @Field(() => SortOrder, { nullable: true })
+ @HideField()
workspaceId?: keyof typeof SortOrder;
@Field(() => WorkspaceMemberCountOrderByAggregateInput, { nullable: true })
diff --git a/server/src/api/@generated/workspace-member/workspace-member-order-by-with-relation.input.ts b/server/src/api/@generated/workspace-member/workspace-member-order-by-with-relation.input.ts
index 1f45dee912a..341d573ac9e 100644
--- a/server/src/api/@generated/workspace-member/workspace-member-order-by-with-relation.input.ts
+++ b/server/src/api/@generated/workspace-member/workspace-member-order-by-with-relation.input.ts
@@ -1,6 +1,7 @@
import { Field } from '@nestjs/graphql';
import { InputType } from '@nestjs/graphql';
import { SortOrder } from '../prisma/sort-order.enum';
+import { HideField } from '@nestjs/graphql';
import { UserOrderByWithRelationInput } from '../user/user-order-by-with-relation.input';
import { WorkspaceOrderByWithRelationInput } from '../workspace/workspace-order-by-with-relation.input';
@@ -21,12 +22,12 @@ export class WorkspaceMemberOrderByWithRelationInput {
@Field(() => SortOrder, { nullable: true })
userId?: keyof typeof SortOrder;
- @Field(() => SortOrder, { nullable: true })
+ @HideField()
workspaceId?: keyof typeof SortOrder;
@Field(() => UserOrderByWithRelationInput, { nullable: true })
user?: UserOrderByWithRelationInput;
- @Field(() => WorkspaceOrderByWithRelationInput, { nullable: true })
+ @HideField()
workspace?: WorkspaceOrderByWithRelationInput;
}
diff --git a/server/src/api/@generated/workspace-member/workspace-member-scalar-where-with-aggregates.input.ts b/server/src/api/@generated/workspace-member/workspace-member-scalar-where-with-aggregates.input.ts
index 71dcbfd09fa..b8b3981205b 100644
--- a/server/src/api/@generated/workspace-member/workspace-member-scalar-where-with-aggregates.input.ts
+++ b/server/src/api/@generated/workspace-member/workspace-member-scalar-where-with-aggregates.input.ts
@@ -3,6 +3,7 @@ import { InputType } from '@nestjs/graphql';
import { StringWithAggregatesFilter } from '../prisma/string-with-aggregates-filter.input';
import { DateTimeWithAggregatesFilter } from '../prisma/date-time-with-aggregates-filter.input';
import { DateTimeNullableWithAggregatesFilter } from '../prisma/date-time-nullable-with-aggregates-filter.input';
+import { HideField } from '@nestjs/graphql';
@InputType()
export class WorkspaceMemberScalarWhereWithAggregatesInput {
@@ -36,6 +37,6 @@ export class WorkspaceMemberScalarWhereWithAggregatesInput {
@Field(() => StringWithAggregatesFilter, { nullable: true })
userId?: StringWithAggregatesFilter;
- @Field(() => StringWithAggregatesFilter, { nullable: true })
+ @HideField()
workspaceId?: StringWithAggregatesFilter;
}
diff --git a/server/src/api/@generated/workspace-member/workspace-member-scalar-where.input.ts b/server/src/api/@generated/workspace-member/workspace-member-scalar-where.input.ts
index 96bb93deaea..7803e3713e4 100644
--- a/server/src/api/@generated/workspace-member/workspace-member-scalar-where.input.ts
+++ b/server/src/api/@generated/workspace-member/workspace-member-scalar-where.input.ts
@@ -3,6 +3,7 @@ import { InputType } from '@nestjs/graphql';
import { StringFilter } from '../prisma/string-filter.input';
import { DateTimeFilter } from '../prisma/date-time-filter.input';
import { DateTimeNullableFilter } from '../prisma/date-time-nullable-filter.input';
+import { HideField } from '@nestjs/graphql';
@InputType()
export class WorkspaceMemberScalarWhereInput {
@@ -30,6 +31,6 @@ export class WorkspaceMemberScalarWhereInput {
@Field(() => StringFilter, { nullable: true })
userId?: StringFilter;
- @Field(() => StringFilter, { nullable: true })
+ @HideField()
workspaceId?: StringFilter;
}
diff --git a/server/src/api/@generated/workspace-member/workspace-member-unchecked-create-without-user.input.ts b/server/src/api/@generated/workspace-member/workspace-member-unchecked-create-without-user.input.ts
index 74b76533b23..7cd761b7373 100644
--- a/server/src/api/@generated/workspace-member/workspace-member-unchecked-create-without-user.input.ts
+++ b/server/src/api/@generated/workspace-member/workspace-member-unchecked-create-without-user.input.ts
@@ -1,5 +1,6 @@
import { Field } from '@nestjs/graphql';
import { InputType } from '@nestjs/graphql';
+import { HideField } from '@nestjs/graphql';
@InputType()
export class WorkspaceMemberUncheckedCreateWithoutUserInput {
@@ -15,6 +16,6 @@ export class WorkspaceMemberUncheckedCreateWithoutUserInput {
@Field(() => Date, { nullable: true })
deletedAt?: Date | string;
- @Field(() => String, { nullable: false })
+ @HideField()
workspaceId!: string;
}
diff --git a/server/src/api/@generated/workspace-member/workspace-member-unchecked-create.input.ts b/server/src/api/@generated/workspace-member/workspace-member-unchecked-create.input.ts
index 38e126a1e96..2eac82334d1 100644
--- a/server/src/api/@generated/workspace-member/workspace-member-unchecked-create.input.ts
+++ b/server/src/api/@generated/workspace-member/workspace-member-unchecked-create.input.ts
@@ -1,5 +1,6 @@
import { Field } from '@nestjs/graphql';
import { InputType } from '@nestjs/graphql';
+import { HideField } from '@nestjs/graphql';
@InputType()
export class WorkspaceMemberUncheckedCreateInput {
@@ -18,6 +19,6 @@ export class WorkspaceMemberUncheckedCreateInput {
@Field(() => String, { nullable: false })
userId!: string;
- @Field(() => String, { nullable: false })
+ @HideField()
workspaceId!: string;
}
diff --git a/server/src/api/@generated/workspace-member/workspace-member-unchecked-update-many.input.ts b/server/src/api/@generated/workspace-member/workspace-member-unchecked-update-many.input.ts
index 69d3ad722e1..ec76968a038 100644
--- a/server/src/api/@generated/workspace-member/workspace-member-unchecked-update-many.input.ts
+++ b/server/src/api/@generated/workspace-member/workspace-member-unchecked-update-many.input.ts
@@ -3,6 +3,7 @@ import { InputType } from '@nestjs/graphql';
import { StringFieldUpdateOperationsInput } from '../prisma/string-field-update-operations.input';
import { DateTimeFieldUpdateOperationsInput } from '../prisma/date-time-field-update-operations.input';
import { NullableDateTimeFieldUpdateOperationsInput } from '../prisma/nullable-date-time-field-update-operations.input';
+import { HideField } from '@nestjs/graphql';
@InputType()
export class WorkspaceMemberUncheckedUpdateManyInput {
@@ -21,6 +22,6 @@ export class WorkspaceMemberUncheckedUpdateManyInput {
@Field(() => StringFieldUpdateOperationsInput, { nullable: true })
userId?: StringFieldUpdateOperationsInput;
- @Field(() => StringFieldUpdateOperationsInput, { nullable: true })
+ @HideField()
workspaceId?: StringFieldUpdateOperationsInput;
}
diff --git a/server/src/api/@generated/workspace-member/workspace-member-unchecked-update-without-user.input.ts b/server/src/api/@generated/workspace-member/workspace-member-unchecked-update-without-user.input.ts
index acc39f54d8a..47df86412cf 100644
--- a/server/src/api/@generated/workspace-member/workspace-member-unchecked-update-without-user.input.ts
+++ b/server/src/api/@generated/workspace-member/workspace-member-unchecked-update-without-user.input.ts
@@ -3,6 +3,7 @@ import { InputType } from '@nestjs/graphql';
import { StringFieldUpdateOperationsInput } from '../prisma/string-field-update-operations.input';
import { DateTimeFieldUpdateOperationsInput } from '../prisma/date-time-field-update-operations.input';
import { NullableDateTimeFieldUpdateOperationsInput } from '../prisma/nullable-date-time-field-update-operations.input';
+import { HideField } from '@nestjs/graphql';
@InputType()
export class WorkspaceMemberUncheckedUpdateWithoutUserInput {
@@ -18,6 +19,6 @@ export class WorkspaceMemberUncheckedUpdateWithoutUserInput {
@Field(() => NullableDateTimeFieldUpdateOperationsInput, { nullable: true })
deletedAt?: NullableDateTimeFieldUpdateOperationsInput;
- @Field(() => StringFieldUpdateOperationsInput, { nullable: true })
+ @HideField()
workspaceId?: StringFieldUpdateOperationsInput;
}
diff --git a/server/src/api/@generated/workspace-member/workspace-member-unchecked-update.input.ts b/server/src/api/@generated/workspace-member/workspace-member-unchecked-update.input.ts
index 7eefc2945c8..d923de7cee4 100644
--- a/server/src/api/@generated/workspace-member/workspace-member-unchecked-update.input.ts
+++ b/server/src/api/@generated/workspace-member/workspace-member-unchecked-update.input.ts
@@ -3,6 +3,7 @@ import { InputType } from '@nestjs/graphql';
import { StringFieldUpdateOperationsInput } from '../prisma/string-field-update-operations.input';
import { DateTimeFieldUpdateOperationsInput } from '../prisma/date-time-field-update-operations.input';
import { NullableDateTimeFieldUpdateOperationsInput } from '../prisma/nullable-date-time-field-update-operations.input';
+import { HideField } from '@nestjs/graphql';
@InputType()
export class WorkspaceMemberUncheckedUpdateInput {
@@ -21,6 +22,6 @@ export class WorkspaceMemberUncheckedUpdateInput {
@Field(() => StringFieldUpdateOperationsInput, { nullable: true })
userId?: StringFieldUpdateOperationsInput;
- @Field(() => StringFieldUpdateOperationsInput, { nullable: true })
+ @HideField()
workspaceId?: StringFieldUpdateOperationsInput;
}
diff --git a/server/src/api/@generated/workspace-member/workspace-member-update-without-user.input.ts b/server/src/api/@generated/workspace-member/workspace-member-update-without-user.input.ts
index 40f51e018a7..d70263f2a30 100644
--- a/server/src/api/@generated/workspace-member/workspace-member-update-without-user.input.ts
+++ b/server/src/api/@generated/workspace-member/workspace-member-update-without-user.input.ts
@@ -4,6 +4,7 @@ import { StringFieldUpdateOperationsInput } from '../prisma/string-field-update-
import { DateTimeFieldUpdateOperationsInput } from '../prisma/date-time-field-update-operations.input';
import { NullableDateTimeFieldUpdateOperationsInput } from '../prisma/nullable-date-time-field-update-operations.input';
import { WorkspaceUpdateOneRequiredWithoutWorkspaceMemberNestedInput } from '../workspace/workspace-update-one-required-without-workspace-member-nested.input';
+import { HideField } from '@nestjs/graphql';
@InputType()
export class WorkspaceMemberUpdateWithoutUserInput {
@@ -19,8 +20,6 @@ export class WorkspaceMemberUpdateWithoutUserInput {
@Field(() => NullableDateTimeFieldUpdateOperationsInput, { nullable: true })
deletedAt?: NullableDateTimeFieldUpdateOperationsInput;
- @Field(() => WorkspaceUpdateOneRequiredWithoutWorkspaceMemberNestedInput, {
- nullable: true,
- })
+ @HideField()
workspace?: WorkspaceUpdateOneRequiredWithoutWorkspaceMemberNestedInput;
}
diff --git a/server/src/api/@generated/workspace-member/workspace-member-update.input.ts b/server/src/api/@generated/workspace-member/workspace-member-update.input.ts
index e6ec2b48d8e..dd9f05c920b 100644
--- a/server/src/api/@generated/workspace-member/workspace-member-update.input.ts
+++ b/server/src/api/@generated/workspace-member/workspace-member-update.input.ts
@@ -5,6 +5,7 @@ import { DateTimeFieldUpdateOperationsInput } from '../prisma/date-time-field-up
import { NullableDateTimeFieldUpdateOperationsInput } from '../prisma/nullable-date-time-field-update-operations.input';
import { UserUpdateOneRequiredWithoutWorkspaceMemberNestedInput } from '../user/user-update-one-required-without-workspace-member-nested.input';
import { WorkspaceUpdateOneRequiredWithoutWorkspaceMemberNestedInput } from '../workspace/workspace-update-one-required-without-workspace-member-nested.input';
+import { HideField } from '@nestjs/graphql';
@InputType()
export class WorkspaceMemberUpdateInput {
@@ -25,8 +26,6 @@ export class WorkspaceMemberUpdateInput {
})
user?: UserUpdateOneRequiredWithoutWorkspaceMemberNestedInput;
- @Field(() => WorkspaceUpdateOneRequiredWithoutWorkspaceMemberNestedInput, {
- nullable: true,
- })
+ @HideField()
workspace?: WorkspaceUpdateOneRequiredWithoutWorkspaceMemberNestedInput;
}
diff --git a/server/src/api/@generated/workspace-member/workspace-member-where.input.ts b/server/src/api/@generated/workspace-member/workspace-member-where.input.ts
index 9a83387a898..84721be42c3 100644
--- a/server/src/api/@generated/workspace-member/workspace-member-where.input.ts
+++ b/server/src/api/@generated/workspace-member/workspace-member-where.input.ts
@@ -3,6 +3,7 @@ import { InputType } from '@nestjs/graphql';
import { StringFilter } from '../prisma/string-filter.input';
import { DateTimeFilter } from '../prisma/date-time-filter.input';
import { DateTimeNullableFilter } from '../prisma/date-time-nullable-filter.input';
+import { HideField } from '@nestjs/graphql';
import { UserRelationFilter } from '../user/user-relation-filter.input';
import { WorkspaceRelationFilter } from '../workspace/workspace-relation-filter.input';
@@ -32,12 +33,12 @@ export class WorkspaceMemberWhereInput {
@Field(() => StringFilter, { nullable: true })
userId?: StringFilter;
- @Field(() => StringFilter, { nullable: true })
+ @HideField()
workspaceId?: StringFilter;
@Field(() => UserRelationFilter, { nullable: true })
user?: UserRelationFilter;
- @Field(() => WorkspaceRelationFilter, { nullable: true })
+ @HideField()
workspace?: WorkspaceRelationFilter;
}
diff --git a/server/src/api/@generated/workspace/workspace.model.ts b/server/src/api/@generated/workspace/workspace.model.ts
index b6e14990d1e..45332bb7d4b 100644
--- a/server/src/api/@generated/workspace/workspace.model.ts
+++ b/server/src/api/@generated/workspace/workspace.model.ts
@@ -6,7 +6,7 @@ import { Company } from '../company/company.model';
import { Person } from '../person/person.model';
import { WorkspaceCount } from './workspace-count.output';
-@ObjectType()
+@ObjectType({})
export class Workspace {
@Field(() => ID, { nullable: false })
id!: string;
diff --git a/server/src/api/api.module.ts b/server/src/api/api.module.ts
index 92a8c99ed74..069a657cd61 100644
--- a/server/src/api/api.module.ts
+++ b/server/src/api/api.module.ts
@@ -3,15 +3,16 @@ import { GraphQLModule } from '@nestjs/graphql';
import { ApolloDriver, ApolloDriverConfig } from '@nestjs/apollo';
import { CompanyResolver } from './resolvers/company.resolver';
import { UserResolver } from './resolvers/user.resolver';
-import { PeopleResolver } from './resolvers/people.resolver';
+import { PersonResolver } from './resolvers/person.resolver';
-import { PersonRelationsResolver } from './resolvers/relations/people-relations.resolver';
+import { PersonRelationsResolver } from './resolvers/relations/person-relations.resolver';
import { UserRelationsResolver } from './resolvers/relations/user-relations.resolver';
import { WorkspaceMemberRelationsResolver } from './resolvers/relations/workspace-member-relations.resolver';
import { ConfigService } from '@nestjs/config';
import { AuthModule } from 'src/auth/auth.module';
import { CompanyRelationsResolver } from './resolvers/relations/company-relations.resolver';
import { PrismaModule } from 'src/database/prisma.module';
+import { ArgsService } from './resolvers/services/args.service';
@Module({
imports: [
@@ -25,9 +26,10 @@ import { PrismaModule } from 'src/database/prisma.module';
],
providers: [
ConfigService,
+ ArgsService,
CompanyResolver,
- PeopleResolver,
+ PersonResolver,
UserResolver,
CompanyRelationsResolver,
diff --git a/server/src/api/resolvers/company.resolver.ts b/server/src/api/resolvers/company.resolver.ts
index d7623b00da8..f6b53b3ab4d 100644
--- a/server/src/api/resolvers/company.resolver.ts
+++ b/server/src/api/resolvers/company.resolver.ts
@@ -1,37 +1,39 @@
import { Resolver, Query, Args, Mutation } from '@nestjs/graphql';
import { JwtAuthGuard } from 'src/auth/guards/jwt.auth.guard';
import { UseGuards } from '@nestjs/common';
-import { User, UserType } from './decorators/user.decorator';
+import { AuthWorkspace } from './decorators/auth-workspace.decorator';
import { PrismaService } from 'src/database/prisma.service';
import { Company } from '../@generated/company/company.model';
import { FindManyCompanyArgs } from '../@generated/company/find-many-company.args';
-import { DeleteOneCompanyArgs } from '../@generated/company/delete-one-company.args';
import { UpdateOneCompanyArgs } from '../@generated/company/update-one-company.args';
import { CreateOneCompanyArgs } from '../@generated/company/create-one-company.args';
import { AffectedRows } from '../@generated/prisma/affected-rows.output';
import { DeleteManyCompanyArgs } from '../@generated/company/delete-many-company.args';
+import { Workspace } from '@prisma/client';
+import { ArgsService } from './services/args.service';
+import { CheckWorkspaceOwnership } from 'src/auth/guards/check-workspace-ownership.guard';
+@UseGuards(JwtAuthGuard, CheckWorkspaceOwnership)
@Resolver(() => Company)
export class CompanyResolver {
- constructor(private readonly prismaService: PrismaService) {}
+ constructor(
+ private readonly prismaService: PrismaService,
+ private readonly argsService: ArgsService,
+ ) {}
- @UseGuards(JwtAuthGuard)
@Query(() => [Company])
- async companies(@Args() args: FindManyCompanyArgs) {
- return this.prismaService.company.findMany(args);
+ async findManyCompany(
+ @Args() args: FindManyCompanyArgs,
+ @AuthWorkspace() workspace: Workspace,
+ ) {
+ const preparedArgs =
+ await this.argsService.prepareFindManyArgs<FindManyCompanyArgs>(
+ args,
+ workspace,
+ );
+ return this.prismaService.company.findMany(preparedArgs);
}
- @UseGuards(JwtAuthGuard)
- @Mutation(() => Company, {
- nullable: true,
- })
- async deleteOneCompany(
- @Args() args: DeleteOneCompanyArgs,
- ): Promise<Company | null> {
- return this.prismaService.company.delete(args);
- }
-
- @UseGuards(JwtAuthGuard)
@Mutation(() => Company, {
nullable: true,
})
@@ -46,31 +48,29 @@ export class CompanyResolver {
});
}
- @UseGuards(JwtAuthGuard)
+ @Mutation(() => AffectedRows, {
+ nullable: false,
+ })
+ async deleteManyCompany(
+ @Args() args: DeleteManyCompanyArgs,
+ ): Promise<AffectedRows> {
+ return this.prismaService.company.deleteMany({
+ ...args,
+ });
+ }
+
@Mutation(() => Company, {
nullable: false,
})
async createOneCompany(
@Args() args: CreateOneCompanyArgs,
- @User() user: UserType,
+ @AuthWorkspace() workspace: Workspace,
): Promise<Company> {
return this.prismaService.company.create({
data: {
...args.data,
- ...{ workspace: { connect: { id: user.workspaceId } } },
+ ...{ workspace: { connect: { id: workspace.id } } },
},
});
}
-
- @UseGuards(JwtAuthGuard)
- @Mutation(() => AffectedRows, {
- nullable: false,
- })
- async deleteManyCompany(
- @Args() args: DeleteManyCompanyArgs,
- ): Promise<AffectedRows> {
- return this.prismaService.company.deleteMany({
- ...args,
- });
- }
}
diff --git a/server/src/api/resolvers/decorators/user.decorator.ts b/server/src/api/resolvers/decorators/auth-user.decorator.ts
similarity index 76%
rename from server/src/api/resolvers/decorators/user.decorator.ts
rename to server/src/api/resolvers/decorators/auth-user.decorator.ts
index a075ffcab64..636c98c6d95 100644
--- a/server/src/api/resolvers/decorators/user.decorator.ts
+++ b/server/src/api/resolvers/decorators/auth-user.decorator.ts
@@ -1,14 +1,10 @@
import { ExecutionContext, createParamDecorator } from '@nestjs/common';
import { GqlExecutionContext } from '@nestjs/graphql';
-export const User = createParamDecorator(
+export const AuthUser = createParamDecorator(
(data: unknown, ctx: ExecutionContext) => {
const gqlContext = GqlExecutionContext.create(ctx);
const request = gqlContext.getContext().req;
return request.user;
},
);
-
-export type UserType = {
- workspaceId: string;
-};
diff --git a/server/src/api/resolvers/decorators/auth-workspace.decorator.ts b/server/src/api/resolvers/decorators/auth-workspace.decorator.ts
new file mode 100644
index 00000000000..43a65695b5b
--- /dev/null
+++ b/server/src/api/resolvers/decorators/auth-workspace.decorator.ts
@@ -0,0 +1,10 @@
+import { ExecutionContext, createParamDecorator } from '@nestjs/common';
+import { GqlExecutionContext } from '@nestjs/graphql';
+
+export const AuthWorkspace = createParamDecorator(
+ (data: unknown, ctx: ExecutionContext) => {
+ const gqlContext = GqlExecutionContext.create(ctx);
+ const request = gqlContext.getContext().req;
+ return request.workspace;
+ },
+);
diff --git a/server/src/api/resolvers/people.resolver.ts b/server/src/api/resolvers/person.resolver.ts
similarity index 65%
rename from server/src/api/resolvers/people.resolver.ts
rename to server/src/api/resolvers/person.resolver.ts
index 121507fdf48..90682f522e3 100644
--- a/server/src/api/resolvers/people.resolver.ts
+++ b/server/src/api/resolvers/person.resolver.ts
@@ -1,7 +1,6 @@
import { Resolver, Query, Args, Mutation } from '@nestjs/graphql';
import { UseGuards } from '@nestjs/common';
import { JwtAuthGuard } from 'src/auth/guards/jwt.auth.guard';
-import { User, UserType } from './decorators/user.decorator';
import { PrismaService } from 'src/database/prisma.service';
import { Person } from '../@generated/person/person.model';
import { FindManyPersonArgs } from '../@generated/person/find-many-person.args';
@@ -9,22 +8,36 @@ import { UpdateOnePersonArgs } from '../@generated/person/update-one-person.args
import { CreateOnePersonArgs } from '../@generated/person/create-one-person.args';
import { AffectedRows } from '../@generated/prisma/affected-rows.output';
import { DeleteManyPersonArgs } from '../@generated/person/delete-many-person.args';
+import { Workspace } from '../@generated/workspace/workspace.model';
+import { AuthWorkspace } from './decorators/auth-workspace.decorator';
+import { ArgsService } from './services/args.service';
+import { CheckWorkspaceOwnership } from 'src/auth/guards/check-workspace-ownership.guard';
+@UseGuards(JwtAuthGuard, CheckWorkspaceOwnership)
@Resolver(() => Person)
-export class PeopleResolver {
- constructor(private readonly prismaService: PrismaService) {}
+export class PersonResolver {
+ constructor(
+ private readonly prismaService: PrismaService,
+ private readonly argsService: ArgsService,
+ ) {}
- @UseGuards(JwtAuthGuard)
@Query(() => [Person], {
nullable: false,
})
- async people(@Args() args: FindManyPersonArgs): Promise<Person[]> {
+ async findManyPerson(
+ @Args() args: FindManyPersonArgs,
+ @AuthWorkspace() workspace: Workspace,
+ ): Promise<Person[]> {
+ const preparedArgs =
+ await this.argsService.prepareFindManyArgs<FindManyPersonArgs>(
+ args,
+ workspace,
+ );
return this.prismaService.person.findMany({
- ...args,
+ ...preparedArgs,
});
}
- @UseGuards(JwtAuthGuard)
@Mutation(() => Person, {
nullable: true,
})
@@ -34,36 +47,35 @@ export class PeopleResolver {
if (!args.data.company?.connect?.id) {
args.data.company = { disconnect: true };
}
+
return this.prismaService.person.update({
...args,
});
}
- @UseGuards(JwtAuthGuard)
+ @Mutation(() => AffectedRows, {
+ nullable: false,
+ })
+ async deleteManyPerson(
+ @Args() args: DeleteManyPersonArgs,
+ ): Promise<AffectedRows> {
+ return this.prismaService.person.deleteMany({
+ ...args,
+ });
+ }
+
@Mutation(() => Person, {
nullable: false,
})
async createOnePerson(
@Args() args: CreateOnePersonArgs,
- @User() user: UserType,
+ @AuthWorkspace() workspace: Workspace,
): Promise<Person> {
return this.prismaService.person.create({
data: {
...args.data,
- ...{ workspace: { connect: { id: user.workspaceId } } },
+ ...{ workspace: { connect: { id: workspace.id } } },
},
});
}
-
- @UseGuards(JwtAuthGuard)
- @Mutation(() => AffectedRows, {
- nullable: false,
- })
- async deleteManyPerson(
- @Args() args: DeleteManyPersonArgs,
- ): Promise<AffectedRows> {
- return this.prismaService.person.deleteMany({
- ...args,
- });
- }
}
diff --git a/server/src/api/resolvers/relations/people-relations.resolver.ts b/server/src/api/resolvers/relations/person-relations.resolver.ts
similarity index 100%
rename from server/src/api/resolvers/relations/people-relations.resolver.ts
rename to server/src/api/resolvers/relations/person-relations.resolver.ts
diff --git a/server/src/api/resolvers/services/args.service.ts b/server/src/api/resolvers/services/args.service.ts
new file mode 100644
index 00000000000..11a3b5b3624
--- /dev/null
+++ b/server/src/api/resolvers/services/args.service.ts
@@ -0,0 +1,18 @@
+import { Injectable } from '@nestjs/common';
+import { Workspace } from '@prisma/client';
+
+type FindManyArgsType = { where?: object; orderBy?: object };
+
+@Injectable()
+export class ArgsService {
+ async prepareFindManyArgs<T extends FindManyArgsType>(
+ args: T,
+ workspace: Workspace,
+ ): Promise<T> {
+ args.where = {
+ ...args.where,
+ ...{ workspace: { is: { id: { equals: workspace.id } } } },
+ };
+ return args;
+ }
+}
diff --git a/server/src/api/resolvers/user.resolver.ts b/server/src/api/resolvers/user.resolver.ts
index 8afbd9146fb..3eb9540016d 100644
--- a/server/src/api/resolvers/user.resolver.ts
+++ b/server/src/api/resolvers/user.resolver.ts
@@ -2,31 +2,39 @@ import { Resolver, Query, Args } from '@nestjs/graphql';
import { PrismaService } from 'src/database/prisma.service';
import { UseGuards } from '@nestjs/common';
import { JwtAuthGuard } from 'src/auth/guards/jwt.auth.guard';
+
import { User } from '../@generated/user/user.model';
import { FindManyUserArgs } from '../@generated/user/find-many-user.args';
-import { FindUniqueUserOrThrowArgs } from '../@generated/user/find-unique-user-or-throw.args';
+import { Workspace } from '@prisma/client';
+import { AuthWorkspace } from './decorators/auth-workspace.decorator';
+import { ArgsService } from './services/args.service';
+import { CheckWorkspaceOwnership } from 'src/auth/guards/check-workspace-ownership.guard';
+@UseGuards(JwtAuthGuard, CheckWorkspaceOwnership)
@Resolver(() => User)
export class UserResolver {
- constructor(private readonly prismaService: PrismaService) {}
+ constructor(
+ private readonly prismaService: PrismaService,
+ private readonly argsService: ArgsService,
+ ) {}
- @UseGuards(JwtAuthGuard)
@Query(() => [User], {
nullable: false,
})
- async users(@Args() args: FindManyUserArgs): Promise<User[]> {
+ async findManyUser(
+ @Args() args: FindManyUserArgs,
+ @AuthWorkspace() workspace: Workspace,
+ ): Promise<User[]> {
+ args.where = {
+ ...args.where,
+ ...{
+ WorkspaceMember: {
+ is: { workspace: { is: { id: { equals: workspace.id } } } },
+ },
+ },
+ };
return await this.prismaService.user.findMany({
...args,
});
}
-
- @UseGuards(JwtAuthGuard)
- @Query(() => User, {
- nullable: false,
- })
- async user(@Args() args: FindUniqueUserOrThrowArgs): Promise<User | null> {
- return await this.prismaService.user.findUnique({
- ...args,
- });
- }
}
diff --git a/server/src/auth/google.auth.controller.ts b/server/src/auth/google.auth.controller.ts
index 49aba87cfdc..a813bd9f4fa 100644
--- a/server/src/auth/google.auth.controller.ts
+++ b/server/src/auth/google.auth.controller.ts
@@ -8,8 +8,9 @@ import {
UseGuards,
} from '@nestjs/common';
import { AuthGuard } from '@nestjs/passport';
-import { Request, Response } from 'express';
+import { Response } from 'express';
import { AuthService } from './services/auth.service';
+import { GoogleRequest } from './strategies/google.auth.strategy';
@Controller('auth/google')
export class GoogleAuthController {
@@ -24,10 +25,8 @@ export class GoogleAuthController {
@Get('redirect')
@UseGuards(AuthGuard('google'))
- async googleAuthRedirect(@Req() req: Request, @Res() res: Response) {
- const user = await this.authService.upsertUser(
- req.user as { firstName: string; lastName: string; email: string },
- );
+ async googleAuthRedirect(@Req() req: GoogleRequest, @Res() res: Response) {
+ const user = await this.authService.upsertUser(req.user);
if (!user) {
throw new HttpException(
diff --git a/server/src/auth/guards/check-workspace-ownership.guard.ts b/server/src/auth/guards/check-workspace-ownership.guard.ts
new file mode 100644
index 00000000000..a762bbd024d
--- /dev/null
+++ b/server/src/auth/guards/check-workspace-ownership.guard.ts
@@ -0,0 +1,85 @@
+import {
+ CanActivate,
+ ExecutionContext,
+ HttpException,
+ HttpStatus,
+ Injectable,
+} from '@nestjs/common';
+import { GqlExecutionContext } from '@nestjs/graphql';
+import { Request } from 'express';
+import { PrismaService } from 'src/database/prisma.service';
+
+type OperationEntity = {
+ operation?: string;
+ entity?: string;
+};
+
+@Injectable()
+export class CheckWorkspaceOwnership implements CanActivate {
+ constructor(private prismaService: PrismaService) {}
+
+ async canActivate(context: ExecutionContext): Promise<boolean> {
+ const gqlContext = GqlExecutionContext.create(context);
+ const request = gqlContext.getContext().req;
+
+ const { operation, entity } = this.fetchOperationAndEntity(request);
+ const variables = request.body.variables;
+ const workspace = await request.workspace;
+
+ if (!entity || !operation) {
+ return false;
+ }
+
+ if (operation === 'updateOne') {
+ const object = await this.prismaService[entity].findUniqueOrThrow({
+ where: { id: variables.id },
+ });
+
+ if (!object) {
+ throw new HttpException(
+ { reason: 'Record not found' },
+ HttpStatus.NOT_FOUND,
+ );
+ }
+ if (object.workspaceId !== workspace.id) {
+ throw new HttpException(
+ { reason: 'Record not found' },
+ HttpStatus.NOT_FOUND,
+ );
+ }
+ return true;
+ }
+
+ if (operation === 'deleteMany') {
+ // TODO: write this logic
+ return true;
+ }
+
+ if (operation === 'findMany') {
+ return true;
+ }
+
+ if (operation === 'createOne') {
+ return true;
+ }
+
+ return false;
+ }
+
+ private fetchOperationAndEntity(request: Request): OperationEntity {
+ if (!request.body.operationName) {
+ return { operation: undefined, entity: undefined };
+ }
+
+ const regex =
+ /(updateOne|deleteMany|createOne|findMany)(Person|Company|User)/i;
+ const match = request.body.query.match(regex);
+ if (match) {
+ return {
+ operation: match[1],
+ entity: match[2].toLowerCase(),
+ };
+ }
+ return { operation: undefined, entity: undefined };
+ }
+}
diff --git a/server/src/auth/guards/jwt.auth.guard.ts b/server/src/auth/guards/jwt.auth.guard.ts
index 333a854fde7..d3012b6c02f 100644
--- a/server/src/auth/guards/jwt.auth.guard.ts
+++ b/server/src/auth/guards/jwt.auth.guard.ts
@@ -1,6 +1,8 @@
import {
CanActivate,
ExecutionContext,
+ HttpException,
+ HttpStatus,
Injectable,
UnauthorizedException,
} from '@nestjs/common';
@@ -8,12 +10,15 @@ import { JwtService } from '@nestjs/jwt';
import { GqlExecutionContext } from '@nestjs/graphql';
import { Request } from 'express';
import { ConfigService } from '@nestjs/config';
+import { PrismaService } from 'src/database/prisma.service';
+import { JwtPayload } from '../strategies/jwt.auth.strategy';
@Injectable()
export class JwtAuthGuard implements CanActivate {
constructor(
private jwtService: JwtService,
private configService: ConfigService,
+ private prismaService: PrismaService,
) {}
async canActivate(context: ExecutionContext): Promise<boolean> {
@@ -24,10 +29,34 @@ export class JwtAuthGuard implements CanActivate {
throw new UnauthorizedException();
}
try {
- const payload = await this.jwtService.verifyAsync(token, {
+ const payload: JwtPayload = await this.jwtService.verifyAsync(token, {
secret: this.configService.get('JWT_SECRET'),
});
- request['user'] = payload;
+
+ const user = this.prismaService.user.findUniqueOrThrow({
+ where: { id: payload.userId },
+ });
+
+ if (!user) {
+ throw new HttpException(
+ { reason: 'User does not exist' },
+ HttpStatus.FORBIDDEN,
+ );
+ }
+
+ const workspace = this.prismaService.workspace.findUniqueOrThrow({
+ where: { id: payload.workspaceId },
+ });
+
+ if (!workspace) {
+ throw new HttpException(
+ { reason: 'Workspace does not exist' },
+ HttpStatus.FORBIDDEN,
+ );
+ }
+
+ request.user = user;
+ request.workspace = workspace;
} catch (exception) {
throw new UnauthorizedException();
}
diff --git a/server/src/auth/services/auth.service.ts b/server/src/auth/services/auth.service.ts
index e013161fe90..d0374fab9f6 100644
--- a/server/src/auth/services/auth.service.ts
+++ b/server/src/auth/services/auth.service.ts
@@ -8,6 +8,12 @@ import { RefreshTokenRepository } from 'src/entities/refresh-token/refresh-token
import { v4 } from 'uuid';
import { RefreshToken, User } from '@prisma/client';
+export type UserPayload = {
+ firstName: string;
+ lastName: string;
+ email: string;
+};
+
@Injectable()
export class AuthService {
constructor(
@@ -18,11 +24,7 @@ export class AuthService {
private refreshTokenRepository: RefreshTokenRepository,
) {}
- async upsertUser(rawUser: {
- firstName: string;
- lastName: string;
- email: string;
- }) {
+ async upsertUser(rawUser: UserPayload) {
if (!rawUser.email) {
throw new HttpException(
{ reason: 'Email is missing' },
diff --git a/server/src/auth/strategies/google.auth.strategy.ts b/server/src/auth/strategies/google.auth.strategy.ts
index 4142045bc32..318bd1264db 100644
--- a/server/src/auth/strategies/google.auth.strategy.ts
+++ b/server/src/auth/strategies/google.auth.strategy.ts
@@ -3,6 +3,11 @@ import { Strategy, VerifyCallback } from 'passport-google-oauth20';
import { Injectable } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
+import { Request } from 'express';
+
+export type GoogleRequest = Request & {
+ user: { firstName: string; lastName: string; email: string };
+};
@Injectable()
export class GoogleStrategy extends PassportStrategy(Strategy, 'google') {
diff --git a/server/src/auth/strategies/jwt.auth.strategy.ts b/server/src/auth/strategies/jwt.auth.strategy.ts
index 9a77fda2772..7465345dc31 100644
--- a/server/src/auth/strategies/jwt.auth.strategy.ts
+++ b/server/src/auth/strategies/jwt.auth.strategy.ts
@@ -24,7 +24,7 @@ export class JwtAuthStrategy extends PassportStrategy(Strategy, 'jwt') {
});
}
- async validate(payload: JwtPayload) {
+ async validate(payload: JwtPayload): Promise<JwtPayload> {
return { userId: payload.userId, workspaceId: payload.workspaceId };
}
}
diff --git a/server/src/database/schema.prisma b/server/src/database/schema.prisma
index 9f711faed61..10af19c2196 100644
--- a/server/src/database/schema.prisma
+++ b/server/src/database/schema.prisma
@@ -35,6 +35,7 @@ model User {
@@map("users")
}
+/// @TypeGraphQL.omit(input: true)
model Workspace {
id String @id
createdAt DateTime @default(now())
@@ -57,7 +58,9 @@ model WorkspaceMember {
deletedAt DateTime?
userId String @unique
user User @relation(fields: [userId], references: [id])
+ /// @TypeGraphQL.omit(input: true)
workspaceId String
+ /// @TypeGraphQL.omit(input: true)
workspace Workspace @relation(fields: [workspaceId], references: [id])
@@map("workspace_members")
@@ -105,6 +108,7 @@ model Person {
@@map("people")
}
+/// @TypeGraphQL.omit(input: true)
model RefreshToken {
id String @id
createdAt DateTime @default(now())
diff --git a/server/src/database/seeds/companies.ts b/server/src/database/seeds/companies.ts
index 4aaf839a22c..37c53ebd940 100644
--- a/server/src/database/seeds/companies.ts
+++ b/server/src/database/seeds/companies.ts
@@ -147,4 +147,16 @@ export const seedCompanies = async (prisma: PrismaClient) => {
address: '',
},
});
+
+ await prisma.company.upsert({
+ where: { id: 'a674fa6c-1455-4c57-afaf-dd5dc086361e' },
+ update: {},
+ create: {
+ id: 'a674fa6c-1455-4c57-afaf-dd5dc086361e',
+ name: 'Instagram',
+ domainName: 'instagram.com',
+ workspaceId: '7ed9d212-1c25-4d02-bf25-6aeccf7ea420',
+ address: '',
+ },
+ });
};
diff --git a/server/src/database/seeds/people.ts b/server/src/database/seeds/people.ts
index fbbeef6be45..4caa253f0e8 100644
--- a/server/src/database/seeds/people.ts
+++ b/server/src/database/seeds/people.ts
@@ -209,4 +209,19 @@ export const seedPeople = async (prisma: PrismaClient) => {
},
});
+
+ await prisma.person.upsert({
+ where: { id: '240da2ec-2d40-4e49-8df4-9c6a049190dh' },
+ update: {},
+ create: {
+ id: '240da2ec-2d40-4e49-8df4-9c6a049190dh',
+ firstname: 'Lorie',
+ lastname: 'Vladim',
+ workspaceId: '7ed9d212-1c25-4d02-bf25-6aeccf7ea420',
+ phone: '+33788901235',
+ city: 'Seattle',
+ companyId: 'a674fa6c-1455-4c57-afaf-dd5dc086361e',
+ email: '[email protected]',
+ },
+ });
};