Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6fc901b3ec | |||
| 50e0cf3090 | |||
| d245d15ad6 | |||
| 265837b5cd | |||
| fe0b4d6d8f | |||
| ce1d22ff44 | |||
| b7bfb3e153 |
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@extollo/lib",
|
"name": "@extollo/lib",
|
||||||
"version": "0.5.9",
|
"version": "0.5.12",
|
||||||
"description": "The framework library that lifts up your code.",
|
"description": "The framework library that lifts up your code.",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"types": "lib/index.d.ts",
|
"types": "lib/index.d.ts",
|
||||||
|
|||||||
3
src/auth/external/oauth2/OAuth2Repository.ts
vendored
3
src/auth/external/oauth2/OAuth2Repository.ts
vendored
@@ -1,7 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
Authenticatable,
|
Authenticatable,
|
||||||
AuthenticatableCredentials,
|
AuthenticatableCredentials,
|
||||||
AuthenticatableIdentifier,
|
|
||||||
AuthenticatableRepository,
|
AuthenticatableRepository,
|
||||||
} from '../../types'
|
} from '../../types'
|
||||||
import {Inject, Injectable} from '../../../di'
|
import {Inject, Injectable} from '../../../di'
|
||||||
@@ -46,7 +45,7 @@ export class OAuth2Repository implements AuthenticatableRepository {
|
|||||||
return this.getAuthenticatableFromBearer(credentials.credential)
|
return this.getAuthenticatableFromBearer(credentials.credential)
|
||||||
}
|
}
|
||||||
|
|
||||||
getByIdentifier(id: AuthenticatableIdentifier): Awaitable<Maybe<Authenticatable>> {
|
getByIdentifier(): Awaitable<Maybe<Authenticatable>> {
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -174,13 +174,35 @@ export abstract class Model<T extends Model<T>> extends AppClass implements Bus
|
|||||||
builder.field(field.databaseKey)
|
builder.field(field.databaseKey)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if ( Array.isArray(this.prototype.with) ) {
|
||||||
|
// Try to get the eager-loaded relations statically, if possible
|
||||||
for (const relation of this.prototype.with) {
|
for (const relation of this.prototype.with) {
|
||||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
builder.with(relation)
|
builder.with(relation)
|
||||||
}
|
}
|
||||||
|
} else if ( this.constructor.length < 1 ) {
|
||||||
|
// Otherwise, if we can instantiate the model without any arguments,
|
||||||
|
// do that and get the eager-loaded relations directly.
|
||||||
|
const inst = Container.getContainer().make<Model<any>>(this)
|
||||||
|
if ( Array.isArray(inst.with) ) {
|
||||||
|
for (const relation of inst.with) {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||||
|
// @ts-ignore
|
||||||
|
builder.with(relation)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( this.prototype.scopes ) {
|
||||||
|
// Same thing here. Try to get the scopes statically, if possible
|
||||||
builder.withScopes(this.prototype.scopes)
|
builder.withScopes(this.prototype.scopes)
|
||||||
|
} else if ( this.constructor.length < 1 ) {
|
||||||
|
// Otherwise, try to instantiate the model if possible and load the scopes that way
|
||||||
|
const inst = Container.getContainer().make<Model<any>>(this)
|
||||||
|
builder.withScopes(inst.scopes)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return builder
|
return builder
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -330,7 +330,7 @@ export class AsyncCollection<T> {
|
|||||||
await this.each(async (item, index) => {
|
await this.each(async (item, index) => {
|
||||||
const result = await func(item, index)
|
const result = await func(item, index)
|
||||||
if ( typeof result !== 'undefined' ) {
|
if ( typeof result !== 'undefined' ) {
|
||||||
newItems.push(result as NonNullable<T2>)
|
newItems.push(result as unknown as NonNullable<T2>)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user