Skip to content
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
2 changes: 1 addition & 1 deletion apps/api/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const withRawCypherFiles = (config, ctx) => {
}

// Nx plugins for webpack.
module.exports = composePlugins(withNx(), withRawCypherFiles, (config) => {
module.exports = composePlugins(withNx({}), withRawCypherFiles, (config) => {
// Update the webpack config as needed here.
// e.g. `config.plugins.push(new MyPlugin())`

Expand Down
2 changes: 1 addition & 1 deletion dist/apps/cli/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1539,7 +1539,7 @@ const bootstrap = async () => {
void bootstrap();

var __webpack_export_target__ = exports;
for(var i in __webpack_exports__) __webpack_export_target__[i] = __webpack_exports__[i];
for(var __webpack_i__ in __webpack_exports__) __webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
if(__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, "__esModule", { value: true });
/******/ })()
;
2 changes: 1 addition & 1 deletion knip.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"ignore": [
"dist",
"libs/shared/infra/gql/**",
"libs/shared/infra/gqlgen/**",
"libs/backend/abstract/codegen/**",
"libs/shared/abstract/core/**"
],
Expand Down
30 changes: 14 additions & 16 deletions libs/backend/application/auth/src/user.decorator.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
import type { Auth0IdToken, IUserDto } from '@codelab/shared/abstract/core'
import type { Auth0IdToken } from '@codelab/shared/abstract/core'
import type { ExecutionContext } from '@nestjs/common'

import { User } from '@codelab/backend/domain/user'
import { createParamDecorator } from '@nestjs/common'
import { GqlExecutionContext } from '@nestjs/graphql'

export const CurrentUser = createParamDecorator<
unknown,
ExecutionContext,
IUserDto
>((data: unknown, ctx: ExecutionContext) => {
const gqlContext = GqlExecutionContext.create(ctx)
export const CurrentUser = createParamDecorator<unknown, ExecutionContext>(
(data: unknown, ctx: ExecutionContext) => {
const gqlContext = GqlExecutionContext.create(ctx)

// Check if it's a GraphQL execution context
if (gqlContext.getContext().req && gqlContext.getContext().res) {
return gqlContext.getContext().user
}
// Check if it's a GraphQL execution context
if (gqlContext.getContext().req && gqlContext.getContext().res) {
return gqlContext.getContext().user
}

// Otherwise assume it's a CLI execution context
const httpContext = ctx.switchToHttp().getRequest()
const userSession = httpContext.user as Auth0IdToken
// Otherwise assume it's a CLI execution context
const httpContext = ctx.switchToHttp().getRequest()
const userSession = httpContext.user as Auth0IdToken

return User.fromSession(userSession)
})
return User.fromSession(userSession)
},
)
9 changes: 3 additions & 6 deletions libs/frontend/domain/app/src/repositories/app.repository.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import type { IAppDto, IRef } from '@codelab/shared/abstract/core'
import type {
AppOptions,
AppUniqueWhere,
AppWhere,
} from '@codelab/shared/infra/gqlgen'
import type { AppOptions, AppWhere } from '@codelab/shared/infra/gqlgen'

import {
CACHE_TAGS,
Expand Down Expand Up @@ -54,7 +50,8 @@ export const appRepository: IAppRepository = withTracingMethods('app', {
)
},

findOne: async (where: AppUniqueWhere) => {
// FIXME: make a unique where
findOne: async (where: AppWhere) => {
return (await appRepository.find(where)).items[0]
},

Expand Down
9 changes: 3 additions & 6 deletions libs/frontend/domain/atom/src/repositories/atom.repository.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import type { IAtomRepository } from '@codelab/frontend/abstract/domain'
import type { IAtomDto, IRef } from '@codelab/shared/abstract/core'
import type { NextFetchOptions } from '@codelab/shared/abstract/types'
import type {
AtomOptions,
AtomUniqueWhere,
AtomWhere,
} from '@codelab/shared/infra/gqlgen'
import type { AtomOptions, AtomWhere } from '@codelab/shared/infra/gqlgen'

import {
CACHE_TAGS,
Expand Down Expand Up @@ -61,7 +57,8 @@ export const atomRepository: IAtomRepository = withTracingMethods('atom', {
return await AtomList({ options, where }, { tags: [CACHE_TAGS.ATOM_LIST] })
},

findOne: async (where: AtomUniqueWhere) => {
// FIXME: make a unique where
findOne: async (where: AtomWhere) => {
return (await atomRepository.find(where)).items[0]
},

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { IAuthGuardDto, IRef } from '@codelab/shared/abstract/core'
import type {
AuthGuardOptions,
AuthGuardUniqueWhere,
AuthGuardWhere,
} from '@codelab/shared/infra/gqlgen'

Expand Down Expand Up @@ -55,7 +54,8 @@ export const authGuardRepository: IAuthGuardRepository = {
)
},

findOne: async (where: AuthGuardUniqueWhere) => {
// FIXME: make a unique where
findOne: async (where: AuthGuardWhere) => {
return (await authGuardRepository.find(where)).items[0]
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import type { IComponentRepository } from '@codelab/frontend/abstract/domain'
import type { IComponentDto, IRef } from '@codelab/shared/abstract/core'
import type {
ComponentOptions,
ComponentUniqueWhere,
ComponentWhere,
} from '@codelab/shared/infra/gqlgen'

Expand Down Expand Up @@ -55,7 +54,8 @@ export const componentRepository: IComponentRepository = {
)
},

findOne: async (where: ComponentUniqueWhere) => {
// FIXME: make a unique where
findOne: async (where: ComponentWhere) => {
return (await componentRepository.find(where)).items[0]
},

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import type { IDomainDto, IRef } from '@codelab/shared/abstract/core'
import type {
DomainOptions,
DomainUniqueWhere,
DomainWhere,
} from '@codelab/shared/infra/gqlgen'
import type { DomainOptions, DomainWhere } from '@codelab/shared/infra/gqlgen'

import {
CACHE_TAGS,
Expand Down Expand Up @@ -56,7 +52,8 @@ export const domainRepository: IDomainRepository = {
return DomainList({ options, where }, { tags: [CACHE_TAGS.DOMAIN_LIST] })
},

findOne: async (where: DomainUniqueWhere) => {
// FIXME: make a unique where
findOne: async (where: DomainWhere) => {
return (await domainRepository.find(where)).items[0]
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ import type {
IElementRepository,
} from '@codelab/frontend/abstract/domain'
import type { IElementDto } from '@codelab/shared/abstract/core'
import type {
ElementOptions,
ElementUniqueWhere,
ElementWhere,
} from '@codelab/shared/infra/gqlgen'
import type { ElementOptions, ElementWhere } from '@codelab/shared/infra/gqlgen'

import { disconnectAll, disconnectManyAll } from '@codelab/shared/domain/orm'
import { Validator } from '@codelab/shared/infra/typebox'
Expand Down Expand Up @@ -51,11 +47,13 @@ export const elementRepository: IElementRepository = {
return await ElementList({ options, where })
},

findOne: async (where: ElementUniqueWhere) => {
// FIXME: make a unique where
findOne: async (where: ElementWhere) => {
return (await elementRepository.find(where)).items[0]
},

update: async (where: ElementUniqueWhere, element: IElementDto) => {
// FIXME: make a unique where
update: async (where: ElementWhere, element: IElementDto) => {
console.debug(elementMapper.toUpdateInput(element))

// Disconnect here first for pre/post, issue with generated cypher query
Expand Down
9 changes: 3 additions & 6 deletions libs/frontend/domain/page/src/repositories/page.repository.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import type { IPageDto, IRef } from '@codelab/shared/abstract/core'
import type {
PageOptions,
PageUniqueWhere,
PageWhere,
} from '@codelab/shared/infra/gqlgen'
import type { PageOptions, PageWhere } from '@codelab/shared/infra/gqlgen'

import {
CACHE_TAGS,
Expand Down Expand Up @@ -48,7 +44,8 @@ export const pageRepository: IPageRepository = {
return PageList({ options, where })
},

findOne: async (where: PageUniqueWhere) => {
// FIXME: make a unique where
findOne: async (where: PageWhere) => {
return (await pageRepository.find(where)).items[0]
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import type {
import type { IPreferenceDto, IRef } from '@codelab/shared/abstract/core'
import type {
PreferenceOptions,
PreferenceUniqueWhere,
PreferenceWhere,
} from '@codelab/shared/infra/gqlgen'

Expand Down Expand Up @@ -54,7 +53,8 @@ export const preferenceRepository: IPreferenceRepository = {
return await GetPreferences({ options, where })
},

findOne: async (where: PreferenceUniqueWhere) => {
// FIXME: make a unique where
findOne: async (where: PreferenceWhere) => {
return (await preferenceRepository.find(where)).items[0]
},

Expand Down
9 changes: 3 additions & 6 deletions libs/frontend/domain/prop/src/repositories/prop.repository.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import type { IPropRepository } from '@codelab/frontend/abstract/domain'
import type { IPropDto, IRef } from '@codelab/shared/abstract/core'
import type {
PropOptions,
PropUniqueWhere,
PropWhere,
} from '@codelab/shared/infra/gqlgen'
import type { PropOptions, PropWhere } from '@codelab/shared/infra/gqlgen'

import { Validator } from '@codelab/shared/infra/typebox'
import {
Expand Down Expand Up @@ -43,7 +39,8 @@ export const propRepository: IPropRepository = {
return await GetProps({ options, where })
},

findOne: async (where: PropUniqueWhere) => {
// FIXME: make a unique where
findOne: async (where: PropWhere) => {
return (await propRepository.find(where)).items[0]
},

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { IRef, IResourceDto } from '@codelab/shared/abstract/core'
import type {
ResourceOptions,
ResourceUniqueWhere,
ResourceWhere,
} from '@codelab/shared/infra/gqlgen'

Expand Down Expand Up @@ -56,7 +55,8 @@ export const resourceRepository: IResourceRepository = {
)
},

findOne: async (where: ResourceUniqueWhere) => {
// FIXME: make a unique where
findOne: async (where: ResourceWhere) => {
return (await resourceRepository.find(where)).items[0]
},

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import type { IRef, IStoreDto } from '@codelab/shared/abstract/core'
import type {
StoreOptions,
StoreUniqueWhere,
StoreWhere,
} from '@codelab/shared/infra/gqlgen'
import type { StoreOptions, StoreWhere } from '@codelab/shared/infra/gqlgen'

import {
CACHE_TAGS,
Expand Down Expand Up @@ -53,7 +49,8 @@ export const storeRepository: IStoreRepository = withTracingMethods('store', {
)
},

findOne: async (where: StoreUniqueWhere) => {
// FIXME: make a unique where
findOne: async (where: StoreWhere) => {
return (await storeRepository.find(where)).items[0]
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ import type {
IFieldRepository,
} from '@codelab/frontend/abstract/domain'
import type { IFieldDto, IRef } from '@codelab/shared/abstract/core'
import type {
FieldOptions,
FieldUniqueWhere,
FieldWhere,
} from '@codelab/shared/infra/gqlgen'
import type { FieldOptions, FieldWhere } from '@codelab/shared/infra/gqlgen'

import { Validator } from '@codelab/shared/infra/typebox'
import {
Expand Down Expand Up @@ -49,7 +45,8 @@ export const fieldRepository: IFieldRepository = {
return await GetFields({ options, where })
},

findOne: async (where: FieldUniqueWhere) => {
// FIXME: make a unique where
findOne: async (where: FieldWhere) => {
return (await fieldRepository.find(where)).items[0]
},

Expand Down
10 changes: 4 additions & 6 deletions libs/shared/abstract/types/src/graphql/where.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export type BaseUniqueWhere =
export type BaseWhere =
| {
[key: string]: unknown
}
Expand All @@ -7,16 +7,14 @@ export type BaseUniqueWhere =
}

export type BaseTypeUniqueWhere =
| BaseUniqueWhere
| BaseWhere
| {
name: string
}

export type UserWhere =
| BaseUniqueWhere
| BaseTypeUniqueWhere
| { auth0Id: string }
| { email: string }

export type BaseTypeUniqueWhereCallback<T, R = BaseTypeUniqueWhere> = (
data: T,
) => R
export type BaseTypeWhereCallback<T, R = BaseTypeUniqueWhere> = (data: T) => R
4 changes: 0 additions & 4 deletions libs/shared/domain/module/component/src/component.mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ export const componentMapper: IMapper<
id,
owner: connectOwner(owner),
props: {
// connectOrCreate: {
// onCreate: { node: propMapper.toCreateInput(props) },
// where: { node: { id: props.id } },
// },
create: {
node: propMapper.toCreateInput(props),
},
Expand Down
6 changes: 0 additions & 6 deletions libs/shared/domain/module/element/src/element.mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,6 @@ export const elementMapper: IMapper<
// : undefined,
prevSibling: connectNodeId(prevSibling?.id),
props: {
// connectOrCreate: {
// onCreate: {
// node: propMapper.toCreateInput(props),
// },
// where: { node: { id: props.id } },
// },
create: {
node: propMapper.toCreateInput(props),
},
Expand Down
Loading