Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make sure Prisma code gets generated on Nx Cloud Agent #14

Merged
merged 4 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,6 @@ jobs:
with:
node-version: 20.10.0
number-of-agents: 3
install-commands: |
pnpm install --frozen-lockfile
pnpm prisma generate
6 changes: 5 additions & 1 deletion api-schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ type Query {
appConfig: AppConfig!
me: User
uptime: Float!
userFindManyIdentity: [Identity!]
userFindManyIdentity(input: UserFindManyIdentityInput!): [Identity!]
userFindManyUser(input: UserFindManyUserInput!): UserPaging!
userFindOneUser(username: String!): User
userRequestIdentityChallenge(input: RequestIdentityChallengeInput!): IdentityChallenge
Expand Down Expand Up @@ -163,6 +163,10 @@ type User {
username: String
}

input UserFindManyIdentityInput {
username: String!
}

input UserFindManyUserInput {
limit: Int = 10
page: Int = 1
Expand Down
8 changes: 7 additions & 1 deletion libs/api/core/feature/src/lib/api-core-feature.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ import { ApiUserFeatureModule } from '@pubkey-stack/api-user-feature'
import { ApiCoreController } from './api-core.controller'
import { ApiCoreResolver } from './api-core.resolver'

const imports = [ApiAuthFeatureModule, ApiCoreDataAccessModule, ApiIdentityFeatureModule, ApiUserFeatureModule]
const imports = [
// The api-feature generator will add the imports here
ApiAuthFeatureModule,
ApiCoreDataAccessModule,
ApiIdentityFeatureModule,
ApiUserFeatureModule,
]

@Module({
controllers: [ApiCoreController],
Expand Down
1 change: 1 addition & 0 deletions libs/api/identity/data-access/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export * from './lib/dto/admin-create-identity.input'
export * from './lib/dto/admin-find-many-identity.input'
export * from './lib/dto/link-identity-input'
export * from './lib/dto/request-identity-challenge.input'
export * from './lib/dto/user-find-many-identity-input'
export * from './lib/dto/verify-identity-challenge-input'
export * from './lib/entity/identity-challenge.entity'
export * from './lib/entity/identity-provider.enum'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { verifySignature } from '@pubkeyapp/solana-verify-wallet'
import { ApiSolanaIdentityService } from './api-solana-identity.service'
import { LinkIdentityInput } from './dto/link-identity-input'
import { RequestIdentityChallengeInput } from './dto/request-identity-challenge.input'
import { UserFindManyIdentityInput } from './dto/user-find-many-identity-input'
import { VerifyIdentityChallengeInput } from './dto/verify-identity-challenge-input'
import { sha256 } from './helpers/sha256'

Expand All @@ -31,9 +32,9 @@ export class ApiUserIdentityService {
return true
}

async findManyIdentity(userId: string): Promise<PrismaIdentity[]> {
async findManyIdentity(input: UserFindManyIdentityInput): Promise<PrismaIdentity[]> {
const items = await this.core.data.identity.findMany({
where: { ownerId: userId },
where: { owner: { username: input.username } },
orderBy: [{ provider: 'asc' }, { providerId: 'asc' }],
})

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Field, InputType } from '@nestjs/graphql'

@InputType()
export class UserFindManyIdentityInput {
@Field()
username!: string
}
14 changes: 7 additions & 7 deletions libs/api/identity/feature/src/lib/api-user-identity.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,45 +8,45 @@ import {
IdentityChallenge,
LinkIdentityInput,
RequestIdentityChallengeInput,
UserFindManyIdentityInput,
VerifyIdentityChallengeInput,
} from '@pubkey-stack/api-identity-data-access'
import { User } from '@pubkey-stack/api-user-data-access'

@Resolver()
@UseGuards(ApiAuthGraphQLUserGuard)
export class ApiUserIdentityResolver {
constructor(private readonly service: ApiIdentityService) {}

@Mutation(() => Boolean, { nullable: true })
userDeleteIdentity(@CtxUser() user: User, @Args('identityId') identityId: string) {
userDeleteIdentity(@CtxUser() user: { id: string }, @Args('identityId') identityId: string) {
return this.service.user.deleteIdentity(user.id, identityId)
}

@Query(() => IdentityChallenge, { nullable: true })
userRequestIdentityChallenge(
@Context() ctx: BaseContext,
@CtxUser() user: User,
@CtxUser() user: { id: string },
@Args('input') input: RequestIdentityChallengeInput,
) {
return this.service.user.requestIdentityChallenge(ctx, user.id, input)
}

@Mutation(() => Identity, { nullable: true })
userLinkIdentity(@CtxUser() user: User, @Args('input') input: LinkIdentityInput) {
userLinkIdentity(@CtxUser() user: { id: string }, @Args('input') input: LinkIdentityInput) {
return this.service.user.linkIdentity(user.id, input)
}

@Mutation(() => IdentityChallenge, { nullable: true })
userVerifyIdentityChallenge(
@Context() ctx: BaseContext,
@CtxUser() user: User,
@CtxUser() user: { id: string },
@Args('input') input: VerifyIdentityChallengeInput,
) {
return this.service.user.verifyIdentityChallenge(ctx, user.id, input)
}

@Query(() => [Identity], { nullable: true })
userFindManyIdentity(@CtxUser() user: User) {
return this.service.user.findManyIdentity(user.id)
userFindManyIdentity(@Args('input') input: UserFindManyIdentityInput) {
return this.service.user.findManyIdentity(input)
}
}
24 changes: 20 additions & 4 deletions libs/sdk/src/generated/graphql-sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,10 @@ export type QueryAnonRequestIdentityChallengeArgs = {
input: RequestIdentityChallengeInput
}

export type QueryUserFindManyIdentityArgs = {
input: UserFindManyIdentityInput
}

export type QueryUserFindManyUserArgs = {
input: UserFindManyUserInput
}
Expand Down Expand Up @@ -259,6 +263,10 @@ export type User = {
username?: Maybe<Scalars['String']['output']>
}

export type UserFindManyIdentityInput = {
username: Scalars['String']['input']
}

export type UserFindManyUserInput = {
limit?: InputMaybe<Scalars['Int']['input']>
page?: InputMaybe<Scalars['Int']['input']>
Expand Down Expand Up @@ -503,7 +511,9 @@ export type AdminDeleteIdentityMutationVariables = Exact<{

export type AdminDeleteIdentityMutation = { __typename?: 'Mutation'; deleted?: boolean | null }

export type UserFindManyIdentityQueryVariables = Exact<{ [key: string]: never }>
export type UserFindManyIdentityQueryVariables = Exact<{
input: UserFindManyIdentityInput
}>

export type UserFindManyIdentityQuery = {
__typename?: 'Query'
Expand Down Expand Up @@ -975,8 +985,8 @@ export const AdminDeleteIdentityDocument = gql`
}
`
export const UserFindManyIdentityDocument = gql`
query userFindManyIdentity {
items: userFindManyIdentity {
query userFindManyIdentity($input: UserFindManyIdentityInput!) {
items: userFindManyIdentity(input: $input) {
...IdentityDetails
}
}
Expand Down Expand Up @@ -1296,7 +1306,7 @@ export function getSdk(client: GraphQLClient, withWrapper: SdkFunctionWrapper =
)
},
userFindManyIdentity(
variables?: UserFindManyIdentityQueryVariables,
variables: UserFindManyIdentityQueryVariables,
requestHeaders?: GraphQLClientRequestHeaders,
): Promise<{
data: UserFindManyIdentityQuery
Expand Down Expand Up @@ -1701,6 +1711,12 @@ export function RequestIdentityChallengeInputSchema(): z.ZodObject<Properties<Re
})
}

export function UserFindManyIdentityInputSchema(): z.ZodObject<Properties<UserFindManyIdentityInput>> {
return z.object({
username: z.string(),
})
}

export function UserFindManyUserInputSchema(): z.ZodObject<Properties<UserFindManyUserInput>> {
return z.object({
limit: z.number().nullish(),
Expand Down
4 changes: 2 additions & 2 deletions libs/sdk/src/graphql/feature-identity.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ mutation adminDeleteIdentity($identityId: String!) {
deleted: adminDeleteIdentity(identityId: $identityId)
}

query userFindManyIdentity {
items: userFindManyIdentity {
query userFindManyIdentity($input: UserFindManyIdentityInput!) {
items: userFindManyIdentity(input: $input) {
...IdentityDetails
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ describe('api-test-feature', () => {
expect(res.data.paging.meta.totalCount).toBeGreaterThan(1)
expect(res.data.paging.data.length).toBeGreaterThan(1)
// First item should be the one we created above
console.log(res.data.paging.data)
expect(res.data.paging.data[0].id).toBe(testId)
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ describe('api-test-feature', () => {
expect(res.data.paging.meta.totalCount).toBeGreaterThan(1);
expect(res.data.paging.data.length).toBeGreaterThan(1);
// First item should be the one we created above
console.log(res.data.paging.data);
expect(res.data.paging.data[0].id).toBe(testId);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ describe('api-<%= model.fileName %>-feature', () => {
expect(res.data.paging.meta.totalCount).toBeGreaterThan(1)
expect(res.data.paging.data.length).toBeGreaterThan(1)
// First item should be the one we created above
console.log(res.data.paging.data)
expect(res.data.paging.data[0].id).toBe(<%= model.propertyName %>Id)
})

Expand Down
4 changes: 3 additions & 1 deletion libs/web/dev/feature/src/lib/dev-identity-wizard.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Grid } from '@mantine/core'
import { IdentityProvider } from '@pubkey-stack/sdk'
import { useAuth } from '@pubkey-stack/web-auth-data-access'
import { useCreateSignature, useUserFindManyIdentity } from '@pubkey-stack/web-identity-data-access'
import { IdentityUiSolanaWizard, IdentityUiSolanaWizardModal } from '@pubkey-stack/web-identity-ui'
import { toastError, toastSuccess, UiCard, UiDebug, UiStack } from '@pubkey-ui/core'
Expand All @@ -8,7 +9,8 @@ import { useWallet } from '@solana/wallet-adapter-react'
import { useCallback } from 'react'

export function DevIdentityWizard() {
const { items } = useUserFindManyIdentity()
const { user } = useAuth()
const { items } = useUserFindManyIdentity({ username: user?.username as string })
const { publicKey } = useWallet()
const challenge = 'Sign this message to verify your wallet'
const createSignature = useCreateSignature()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { Identity, IdentityProvider } from '@pubkey-stack/sdk'
import { Identity, IdentityProvider, type UserFindManyIdentityInput } from '@pubkey-stack/sdk'
import { useSdk } from '@pubkey-stack/web-core-data-access'
import { toastError, toastSuccess } from '@pubkey-ui/core'
import { useQuery } from '@tanstack/react-query'
import { useMemo } from 'react'

export function useUserFindManyIdentity() {
export function useUserFindManyIdentity({ username }: { username: string }) {
const sdk = useSdk()
const input: UserFindManyIdentityInput = useMemo(() => ({ username }), [username])
const query = useQuery({
queryKey: ['user', 'find-many-identity'],
queryFn: () => sdk.userFindManyIdentity().then((res) => res?.data),
queryKey: ['user', 'find-many-identity', input],
queryFn: () => sdk.userFindManyIdentity({ input }).then((res) => res?.data),
})

const grouped: { provider: IdentityProvider; items: Identity[] }[] = useMemo(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { useAuth } from '@pubkey-stack/web-auth-data-access'
import { useUserFindManyIdentity } from '@pubkey-stack/web-identity-data-access'
import { IdentityUiGroupList } from '@pubkey-stack/web-identity-ui'
import { UiLoader, UiStack } from '@pubkey-ui/core'

export function SettingsIdentityFeature() {
const { deleteIdentity, grouped, query } = useUserFindManyIdentity()
const { user } = useAuth()
const { deleteIdentity, grouped, query } = useUserFindManyIdentity({ username: user?.username as string })

return (
<UiStack>
Expand Down
4 changes: 2 additions & 2 deletions libs/web/shell/feature/src/lib/shell-admin-routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import { IconUsers } from '@tabler/icons-react'
import { Navigate, RouteObject, useRoutes } from 'react-router-dom'

const links: UiDashboardItem[] = [
// Admin Dashboard Links
// Admin Dashboard Links are added by the web-feature generator
{ label: 'Users', icon: IconUsers, to: '/admin/users' },
]

const routes: RouteObject[] = [
// Admin Dashboard Routes
// Admin Dashboard Routes are added by the web-feature generator
{ path: 'development/*', element: <DevAdminRoutes /> },
{ path: 'users/*', element: <AdminUserFeature /> },
]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useSdk } from '@pubkey-stack/web-core-data-access'
import { useQuery } from '@tanstack/react-query'

export function useUserFineOneUser(username: string) {
export function useUserFineOneUser({ username }: { username: string }) {
const sdk = useSdk()
const query = useQuery({
queryKey: ['user', 'find-one-user', username],
Expand Down
2 changes: 1 addition & 1 deletion libs/web/user/data-access/src/lib/use-user-profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export function useUserProfile() {
const sdk = useSdk()
const me = useMe(sdk)
const { user } = useAuth()
const { query } = useUserFineOneUser(user?.username as string)
const { query } = useUserFineOneUser({ username: user?.username as string })

return {
user: query.data?.item,
Expand Down
4 changes: 2 additions & 2 deletions libs/web/user/feature/src/lib/user-detail-feature.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import { Link, useParams } from 'react-router-dom'
export function UserDetailFeature() {
const { user: authUser } = useAuth()
const { username } = useParams<{ username: string }>() as { username: string }
const { user, query } = useUserFineOneUser(username)
const { items } = useUserFindManyIdentity()
const { user, query } = useUserFineOneUser({ username })
const { items } = useUserFindManyIdentity({ username })

if (query.isLoading) {
return <UiLoader />
Expand Down
Loading